<!DOCTYPE html>
<html lang="zh" dir="ltr">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>C语言标准库stdlib – 邵晨峰的博客</title>
    


  
  <script defer src="/js/fuse.min.c4bee9a8d44273d6154fe86006923d4131eb2e8069d8897687137c6f37f553e3.js"></script>



<script src="/js/enquire.min.aa37bdcb743826eecdae5c5d177fc7d6552340f1b4378ffaa9c82b2c6111400b.js"></script>

<script defer src="/js/lazysizes.min.5e11d056075a05065b9c0bfec44084a113fc2976c2952ec804dedb61c7662db9.js"></script>

<script defer src="/js/helper/getParents.min.ccd45f158c1b17849307ba913a72beac239c410f2b6e648496a79842da84e55b.js"></script>

<script defer src="/js/helper/fadeinout.min.9fb19682560d5fa5596fffec85da605067c4acc86aad05add4d8fff9d362a446.js"></script>

<script>
  "use strict";
  
  
  var targetProtocol = "http:"; 
  if (window.location.protocol != targetProtocol)
    window.location.href = targetProtocol + window.location.href.substring(window.location.protocol.length);

  
  function baiduSearch(event) {
    var evt = window.event || event;
        if (evt.keyCode == 13) {
          console.log(event)
          var val = document.getElementById("search").value
          if(!val){
                  alert('搜索内容为空，请输入');
                  return false;
          }else{
            val = val + " site:shaochenfeng.com"
            window.open("https://www.baidu.com/s?ie=utf-8&wd=" + val);
          }
        }
  }

  window.onload = function() {
    
    var languagedir = JSON.parse("\"ltr\"");
    
    var baseurl = JSON.parse("\"http://shaochenfeng.com\"");
    
    var permalink = JSON.parse("\"http://shaochenfeng.com/blog/c%E8%AF%AD%E8%A8%80%E6%A0%87%E5%87%86%E5%BA%93stdlib.h%E5%AD%A6%E4%B9%A0/\"");

    
    var toggleSidebarElem = document.getElementById("toggle-sidebar");
    var toggleMenuElem = document.getElementById("toggle-menu");
    var tocBodyElem = document.querySelector('.toc__body');
    var tocLabelElem = document.querySelector('.toc__label');
    var listMainElem = document.getElementById('list-main');
    var listSideElem = document.getElementById('list-side');
    var singleMenuElem = document.getElementById('single-menu');
    var sliderIcons = document.querySelectorAll('.slider__icon');

    toggleSidebarElem ?
      toggleSidebarElem.addEventListener('change', function (e) {
        if (e.target.checked) {
          if (tocBodyElem) {
            fadeIn(tocBodyElem, 200);
          }
          if (tocLabelElem) {
            fadeIn(tocLabelElem, 200);
          }
          if (listMainElem && listSideElem) {
            listMainElem.className = 'm';
            listSideElem.className = 'r';
          }

          sliderIcons && sliderIcons.forEach(function (elem) {
            if (elem.classList.contains('hide')) {
              elem.classList.remove('hide');
            } else {
              elem.classList.add('hide');
            }
          });

        } else {
          if (tocBodyElem) {
            fadeOut(tocBodyElem, 200);
          }
          if (tocLabelElem) {
            fadeOut(tocLabelElem, 200);
          }
          if (listMainElem && listSideElem) {
            listMainElem.className = 'mr';
            listSideElem.className = 'hide';
          }

          sliderIcons && sliderIcons.forEach(function (elem) {
            if (elem.classList.contains('hide')) {
              elem.classList.remove('hide');
            } else {
              elem.classList.add('hide');
            }
          });
        }
      }) : null;

    toggleMenuElem ?
      toggleMenuElem.addEventListener('change', function (e) {
        if (e.target.checked) {
          if (listMainElem && singleMenuElem) {
            listMainElem.className = 'm';
            singleMenuElem.className = 'l';
          }

          sliderIcons && sliderIcons.forEach(function (elem) {
            if (elem.classList.contains('hide')) {
              elem.classList.remove('hide');
            } else {
              elem.classList.add('hide');
            }
          });

        } else {
          if (listMainElem && singleMenuElem) {
            listMainElem.className = 'lm';
            singleMenuElem.className = 'hide';
          }

          sliderIcons && sliderIcons.forEach(function (elem) {
            if (elem.classList.contains('hide')) {
              elem.classList.remove('hide');
            } else {
              elem.classList.add('hide');
            }
          });
        }
      }) : null;
    


    
    var navCollapseBtn = document.getElementById('navCollapseBtn');
    navCollapseBtn ? navCollapseBtn.addEventListener('click', function(e) {
      var navCollapse = document.querySelector('.navbar__collapse');
      
      if (navCollapse) {
        var dataOpen = navCollapse.getAttribute('data-open');

        if (dataOpen === 'true') {
          navCollapse.setAttribute('data-open', 'false');
          navCollapse.style.maxHeight = 0;
        } else {
          navCollapse.setAttribute('data-open', 'true');
          navCollapse.style.maxHeight = navCollapse.scrollHeight + "px";
        }
      }
    }) : null;
    


    
    var expandBtn = document.querySelectorAll('.expand__button');

    for (let i = 0; i < expandBtn.length; i++) {
      expandBtn[i].addEventListener("click", function () {
        var content = this.nextElementSibling;
        if (content.style.maxHeight) {
          content.style.maxHeight = null;
          this.querySelector('svg').classList.add('expand-icon__right');
          this.querySelector('svg').classList.remove('expand-icon__down');
        } else {
          content.style.maxHeight = content.scrollHeight + "px";
          this.querySelector('svg').classList.remove('expand-icon__right');
          this.querySelector('svg').classList.add('expand-icon__down');
        }
      });
    }
    



    
    document.querySelectorAll('.tab') ? 
    document.querySelectorAll('.tab').forEach(function(elem, idx) {
      var containerId = elem.getAttribute('id');
      var containerElem = elem;
      var tabLinks = elem.querySelectorAll('.tab__link');
      var tabContents = elem.querySelectorAll('.tab__content');
      var ids = [];

      tabLinks && tabLinks.length > 0 ?
      tabLinks.forEach(function(link, index, self) {
        link.onclick = function(e) {
          for (var i = 0; i < self.length; i++) {
            if (index === parseInt(i, 10)) {
              if (!self[i].classList.contains('active')) {
                self[i].classList.add('active');
                tabContents[i].style.display = 'block';
              }
            } else {
              self[i].classList.remove('active');
              tabContents[i].style.display = 'none';
            }
          }
        }
      }) : null;
    }) : null;
    


    
    document.querySelectorAll('.codetab') ? 
    document.querySelectorAll('.codetab').forEach(function(elem, idx) {
      var containerId = elem.getAttribute('id');
      var containerElem = elem;
      var codetabLinks = elem.querySelectorAll('.codetab__link');
      var codetabContents = elem.querySelectorAll('.codetab__content');
      var ids = [];

      codetabLinks && codetabLinks.length > 0 ?
      codetabLinks.forEach(function(link, index, self) {
        link.onclick = function(e) {
          for (var i = 0; i < self.length; i++) {
            if (index === parseInt(i, 10)) {
              if (!self[i].classList.contains('active')) {
                self[i].classList.add('active');
                codetabContents[i].style.display = 'block';
              }
            } else {
              self[i].classList.remove('active');
              codetabContents[i].style.display = 'none';
            }
          }
        }
      }) : null;
    }) : null;
    

    
    
    
    var enableDarkMode = JSON.parse("true");
    var root = document.getElementById('root');
    var toggleToLightBtn = document.getElementById('toggleToLight');
    var toggleToDarkBtn = document.getElementById('toggleToDark');

    if (!enableDarkMode) {
      root.className = 'theme__light';
      localStorage.setItem('theme', 'light');
    }
    
    if (toggleToDarkBtn) {
      toggleToDarkBtn.onclick = function (e) {
        root.className = 'theme__dark';
        localStorage.setItem('theme', 'dark');
        toggleToLightBtn.className = 'navbar__icons--icon';
        toggleToDarkBtn.className = 'hide';
      }
    }

    if (toggleToLightBtn) {
      toggleToLightBtn.onclick = function (e) {
        root.className = 'theme__light';
        localStorage.setItem('theme', 'light');
        toggleToLightBtn.className = 'hide';
        toggleToDarkBtn.className = 'navbar__icons--icon';
      }
    }

    
    document.querySelectorAll('.menu__list').forEach(function(elem) {
      if (elem.classList.contains('active')) {
        elem.style.maxHeight = elem.scrollHeight + "px"; 
      }
    });
    
    document.querySelectorAll('.menu__title--collapse').forEach(function(elem) {
      elem.addEventListener('click', function (e) {
        var content = this.nextElementSibling;
        var menuTitleIcon = this.querySelector('.menu__title--icon');
        if (!content) {
          return null;
        }

        var parent = elem.parentNode;
        while (parent.classList.contains('menu__list') && parent.classList.contains('active')) {
          parent.style.maxHeight = 100 * parent.children.length + "px";
          parent = parent.parentNode;
        }

        if (content.style.maxHeight) {
          content.style.maxHeight = null;
          content.classList.remove('active');
          menuTitleIcon.classList.add('right');
          
          if (languagedir === 'rtl') {
            menuTitleIcon.classList.remove('downrtl');
          } else {
            menuTitleIcon.classList.remove('down');
          }
        } else {
          content.style.maxHeight = content.scrollHeight + "px";
          content.classList.add('active');
          menuTitleIcon.classList.remove('right');
          
          if (languagedir === 'rtl') {
            menuTitleIcon.classList.add('downrtl');
          } else {
            menuTitleIcon.classList.add('down');
          }
        }
      });
    });
    


    
    var mobileLogo = document.getElementById('mobileLogo');
    var modal = document.getElementById("myModal");
    var drawer = document.getElementById('myDrawer');
    var drawerCloseBtn = document.querySelector('.drawer__close');

    var openDrawer = function() {
      modal.style.opacity = 1;

      if (languagedir === 'rtl') {
        modal.style.right = 0;
        drawer.style.right = 0;
      } else {
        modal.style.left = 0;
        drawer.style.left = 0;
      }
    }

    var closeDrawer = function() {
      modal.style.opacity = 0;

      if (languagedir === 'rtl') {
        drawer.style.right = '-100%';
      } else {
        drawer.style.left = '-100%';
      }

      
      setTimeout(function () {
        if (languagedir === 'rtl') {
          modal.style.right = '-100%';
        } else {
          modal.style.left = '-100%';
        }
      }, 250);
    }

    mobileLogo.onclick = function () {
      openDrawer();
      localStorage.setItem('isDrawerOpen', 'true');
    }

    modal.onclick = function () {
      closeDrawer();
      localStorage.setItem('isDrawerOpen', 'false');
    }

    drawerCloseBtn.onclick = function () {
      closeDrawer();
      localStorage.setItem('isDrawerOpen', 'false');
    }
  


  
    var lastScrollTop = window.pageYOffset || document.documentElement.scrollTop;
    var tocElem = document.querySelector('.toc');
    var tableOfContentsElem = tocElem ? tocElem.querySelector('#TableOfContents') : null;
    var singleContentsElem = document.querySelector('.single__contents');
    var dataBGImgs = document.querySelectorAll('div[data-bgimg]');

    
    var tocLevels = JSON.parse("null");

    if (tocLevels) {
      tocLevels = tocLevels.toString();
    } else {
      tocLevels = "h1, h2, h3, h4, h5, h6";
    }

    
    var isLandingBgImg = JSON.parse("null");
    
    var isHome = JSON.parse("false");

    function setNavbarBG(scrollTop) {
      if (isHome && isLandingBgImg && Object.keys(isLandingBgImg).length) {
        if (isLandingBgImg.height <= scrollTop) {
          dataBGImgs.forEach(function(elem) {
            elem.setAttribute('data-bgimg', 'false');
          });
        } else {
          dataBGImgs.forEach(function (elem) {
            elem.setAttribute('data-bgimg', 'true');
          });
        }
      }
    }
    setNavbarBG(lastScrollTop);

    window.onscroll = function () {
      var st = window.pageYOffset || document.documentElement.scrollTop;
      if (st > lastScrollTop) { 
        singleContentsElem ? 
        singleContentsElem.querySelectorAll(tocLevels.toString()).forEach(function(elem) {
          if (document.documentElement.scrollTop >= elem.offsetTop) {
            if (tableOfContentsElem) {
              var id = elem.getAttribute('id');
              tocElem.querySelectorAll('a').forEach(function (elem) {
                elem.classList.remove('active');
              });
              tocElem.querySelector('a[href="#' + id + '"]') ? 
              tocElem.querySelector('a[href="#' + id + '"]').classList.add('active') : null;
            }
          }
        }) : null;
        setNavbarBG(st);
      } else { 
        singleContentsElem ? 
        singleContentsElem.querySelectorAll(tocLevels.toString()).forEach(function(elem) {
          if (document.documentElement.scrollTop >= elem.offsetTop) {
            if (tableOfContentsElem) {
              var id = elem.getAttribute('id');
              tocElem.querySelectorAll('a').forEach(function (elem) {
                elem.classList.remove('active');
              });
              tocElem.querySelector('a[href="#' + id + '"]') ? 
              tocElem.querySelector('a[href="#' + id + '"]').classList.add('active') : null;
            }
          }
        }) : null;
        setNavbarBG(st);
      }
      lastScrollTop = st <= 0 ? 0 : st;
    };
    



    
    var mobileSearchInputElem = document.querySelector('#search-mobile');
    var mobileSearchClassElem = document.querySelector('.mobile-search');
    var mobileSearchBtnElem = document.querySelector('#mobileSearchBtn');
    var mobileSearchCloseBtnElem = document.querySelector('#search-mobile-close');
    var mobileSearchContainer = document.querySelector('#search-mobile-container');
    var mobileSearchResultsElem = document.querySelector('#search-mobile-results');
    var htmlElem = document.querySelector('html');

    if (mobileSearchClassElem) {
      mobileSearchClassElem.style.display = 'none';
    }

    mobileSearchBtnElem ? 
    mobileSearchBtnElem.addEventListener('click', function () {
      if (mobileSearchContainer) {
        mobileSearchContainer.style.display = 'block';
      }

      if (mobileSearchInputElem) {
        mobileSearchInputElem.focus();
      }

      if (htmlElem) {
        htmlElem.style.overflowY = 'hidden';
      }
    }) : null;

    mobileSearchCloseBtnElem ? 
    mobileSearchCloseBtnElem.addEventListener('click', function() {
      if (mobileSearchContainer) {
        mobileSearchContainer.style.display = 'none';
      }

      if (mobileSearchInputElem) {
        mobileSearchInputElem.value = '';
      }
      
      if (mobileSearchResultsElem) {
        while (mobileSearchResultsElem.firstChild) {
          mobileSearchResultsElem.removeChild(mobileSearchResultsElem.firstChild);
        }
      }

      if (htmlElem) {
        htmlElem.style.overflowY = 'visible';
      }
    }) : null;

    mobileSearchInputElem ? 
    mobileSearchInputElem.addEventListener('keydown', function(e) {
      if (e.key === 'Escape') {
        if (mobileSearchContainer) {
          mobileSearchContainer.style.display = 'none';
        }
        
        if (mobileSearchInputElem) {
          mobileSearchInputElem.value = '';
        }

        if (mobileSearchResultsElem) {
          while (mobileSearchResultsElem.firstChild) {
            mobileSearchResultsElem.removeChild(mobileSearchResultsElem.firstChild);
          }
        }
        if (htmlElem) {
          htmlElem.style.overflowY = 'visible';
        }
      }
    }) : null;
  


  
    var localTheme = localStorage.getItem('theme');
    var rootEleme = document.getElementById('root');
    var selectThemeElem = document.querySelectorAll('.select-theme');
    var selectThemeItemElem = document.querySelectorAll('.select-theme__item');
    
    if (localTheme) {
      selectThemeItemElem ? 
      selectThemeItemElem.forEach(function (elem) {
        if (elem.text.trim() === localTheme) {
          elem.classList.add('is-active');
        } else {
          elem.classList.remove('is-active');
        }
      }) : null;
    }

    selectThemeItemElem ? 
    selectThemeItemElem.forEach(function (v, i) {
      v.addEventListener('click', function (e) {
        var selectedThemeVariant = e.target.text.trim();
        localStorage.setItem('theme', selectedThemeVariant);

        rootEleme.removeAttribute('class');
        rootEleme.classList.add(`theme__${selectedThemeVariant}`);
        selectThemeElem.forEach(function(rootElem) {
          rootElem.querySelectorAll('a').forEach(function (elem) {
            if (elem.classList) {
              if (elem.text.trim() === selectedThemeVariant) {
                if (!elem.classList.contains('is-active')) {
                  elem.classList.add('is-active');
                }
              } else {
                if (elem.classList.contains('is-active')) {
                  elem.classList.remove('is-active');
                }
              }
            }
          });
        });

        if (window.mermaid) {
          if (selectedThemeVariant === "dark" || selectedThemeVariant === "hacker") {
            mermaid.initialize({ theme: 'dark' });
            location.reload();
          } else {
            mermaid.initialize({ theme: 'default' });
            location.reload();
          }
        }

        var utterances = document.querySelector('iframe');
        if (utterances) {
          utterances.contentWindow.postMessage({
            type: 'set-theme',
            theme: selectedThemeVariant === "dark" || selectedThemeVariant === "hacker" ? 'photon-dark' : selectedThemeVariant === 'kimbie' ? 'github-dark-orange' : 'github-light',
          }, 'https://utteranc.es');
        }
      });
    }) : null;
  


  
    
    var langprefix = JSON.parse("\"\"");
    var searchResults = null;
    var searchMenu = null;
    var searchText = null;
    
    
    var enableSearchHighlight = JSON.parse("null");
    
    var enableSearch = JSON.parse("true");

    var fuse = null;

    if (enableSearch) {
      (function initFuse() {
        var xhr = new XMLHttpRequest();
        xhr.open('GET', baseurl + langprefix + "/index.json");
        xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8');
        xhr.onload = function () {
          if (xhr.status === 200) {
            fuse = new Fuse(JSON.parse(xhr.response.toString('utf-8')), {
              keys: ['title', 'description', 'content'],
              includeMatches: enableSearchHighlight,
              shouldSort: true,
              threshold: 0.4,
              location: 0,
              distance: 100,
              maxPatternLength: 32,
              minMatchCharLength: 1,
            });
          }
          else {
            console.error(`[${xhr.status}]Error:`, xhr.statusText);
          }
        };
        xhr.send();
      })();
    }
    
    function makeLi(ulElem, obj) {
      var li = document.createElement('li');
      li.className = 'search-result__item';
      
      var a = document.createElement('a');
      a.innerHTML = obj.title;
      a.setAttribute('class', 'search-result__item--title');
      a.setAttribute('href', obj.permalink);

      var descDiv = document.createElement('div');
      descDiv.setAttribute('class', 'search-result__item--desc');
      if (obj.description) {
        descDiv.innerHTML = obj.description.substring(0, 80);
      } else if (obj.content) {
        descDiv.innerHTML = obj.content.substring(0, 80);
      }
      
      li.appendChild(a);
      li.appendChild(descDiv);
      ulElem.appendChild(li);
    }

    function makeHighlightLi(ulElem, obj) {
      var li = document.createElement('li');
      li.className = 'search-result__item';
      var descDiv = null;

      var a = document.createElement('a');
      a.innerHTML = obj.item.title;
      a.setAttribute('class', 'search-result__item--title');
      a.setAttribute('href', obj.item.uri);

      if (obj.matches && obj.matches.length) {
        for (var i = 0; i < obj.matches.length; i++) {
          if ('title' === obj.matches[i].key) {
            a = document.createElement('a');
            a.innerHTML = generateHighlightedText(obj.matches[i].value, obj.matches[i].indices);
            a.setAttribute('class', 'search-result__item--title');
            a.setAttribute('href', obj.item.uri);
          }
          
          if ('description' === obj.matches[i].key) {
            descDiv = document.createElement('div');
            descDiv.setAttribute('class', 'search-result__item--desc');
            descDiv.innerHTML = generateHighlightedText(obj.item.description, obj.matches[i].indices);
          } else if ('content' === obj.matches[i].key) {
            if (!descDiv) {
              descDiv = document.createElement('div');
              descDiv.setAttribute('class', 'search-result__item--desc');
              descDiv.innerHTML = generateHighlightedText(obj.item.content.substring(0, 80), obj.matches[i].indices);
            }
          } else {
            if (obj.item.description) {
              descDiv = document.createElement('div');
              descDiv.setAttribute('class', 'search-result__item--desc');
              descDiv.innerHTML = obj.item.description;
            } else {
              descDiv = document.createElement('div');
              descDiv.setAttribute('class', 'search-result__item--desc');
              descDiv.innerHTML = obj.item.content.substring(0, 80);
            }
          }
        }

        li.appendChild(a);
        if (descDiv) {
          li.appendChild(descDiv);
        }
        if (li) {
          ulElem.appendChild(li);
        }
      }
    }

    function renderSearchResults(searchText, results) {
      searchResults = document.getElementById('search-results');
      searchMenu = document.getElementById('search-menu');
      searchResults.setAttribute('class', 'dd is-active');
      
      var ul = document.createElement('ul');
      ul.setAttribute('class', 'dd-content search-content');

      if (results.length) {
        results.forEach(function (result) {
          var li = document.createElement('li');
          var a = document.createElement('a');
          a.setAttribute('href', result.uri);
          a.setAttribute('class', 'dd-item');
          a.appendChild(li);

          var titleDiv = document.createElement('div');
          titleDiv.innerHTML = result.title;
          titleDiv.setAttribute('class', 'search-result__item--title');

          var descDiv = document.createElement('div');
          descDiv.setAttribute('class', 'search-result__item--desc');
          if (result.description) {
            descDiv.innerHTML = result.description;
          } else if (result.content) {
            descDiv.innerHTML = result.content.substring(0, 80);
          }

          li.appendChild(titleDiv);
          li.appendChild(descDiv);
          ul.appendChild(a);
        });
      } else {
        var li = document.createElement('li');
        li.setAttribute('class', 'dd-item');
        li.innerText = 'No results found';
        ul.appendChild(li);
      }

      while (searchMenu.hasChildNodes()) {
        searchMenu.removeChild(
          searchMenu.lastChild
        );
      }
      
      searchMenu.appendChild(ul);
    }

    function renderSearchHighlightResults(searchText, results) {
      searchResults = document.getElementById('search-results');
      searchMenu = document.getElementById('search-menu');
      searchResults.setAttribute('class', 'dd is-active');

      var ul = document.createElement('ul');
      ul.setAttribute('class', 'dd-content search-content');

      if (results.length) {
        results.forEach(function (result) {
          var li = document.createElement('li');
          var a = document.createElement('a');
          var descDiv = null;

          a.setAttribute('href', result.item.uri);
          a.setAttribute('class', 'dd-item');
          a.appendChild(li);

          var titleDiv = document.createElement('div');
          titleDiv.innerHTML = result.item.title;
          titleDiv.setAttribute('class', 'search-result__item--title');
          
          if (result.matches && result.matches.length) {
            for (var i = 0; i < result.matches.length; i++) {
              if ('title' === result.matches[i].key) {
                titleDiv.innerHTML = generateHighlightedText(result.matches[i].value, result.matches[i].indices);
              }

              if ('description' === result.matches[i].key) {
                descDiv = document.createElement('div');
                descDiv.setAttribute('class', 'search-result__item--desc');
                descDiv.innerHTML = generateHighlightedText(result.item.description, result.matches[i].indices);
              } else if ('content' === result.matches[i].key) {
                if (!descDiv) {
                  descDiv = document.createElement('div');
                  descDiv.setAttribute('class', 'search-result__item--desc');
                  descDiv.innerHTML = generateHighlightedText(result.item.content.substring(0, 80), result.matches[i].indices);
                }
              } else {
                if (result.item.description) {
                  descDiv = document.createElement('div');
                  descDiv.setAttribute('class', 'search-result__item--desc');
                  descDiv.innerHTML = result.item.description;
                } else {
                  descDiv = document.createElement('div');
                  descDiv.setAttribute('class', 'search-result__item--desc');
                  descDiv.innerHTML = result.item.content.substring(0, 80);
                }
              }
            }
            
            li.appendChild(titleDiv);
            if (descDiv) {
              li.appendChild(descDiv);
            }
            ul.appendChild(a);
          }
        });
      } else {
        var li = document.createElement('li');
        li.setAttribute('class', 'dd-item');
        li.innerText = 'No results found';
        ul.appendChild(li);
      }

      while (searchMenu.hasChildNodes()) {
        searchMenu.removeChild(
          searchMenu.lastChild
        );
      }
      searchMenu.appendChild(ul);
    }

    function renderSearchResultsMobile(searchText, results) {
      searchResults = document.getElementById('search-mobile-results');

      var content = document.createElement('div');
      content.setAttribute('class', 'mobile-search__content');

      if (results.length > 0) {
        results.forEach(function (result) {
          var item = document.createElement('a');
          item.setAttribute('href', result.uri);
          item.innerHTML = '<div class="mobile-search__item"><div class="mobile-search__item--title">📄 ' +
             result.title + '</div><div class="mobile-search__item--desc">' + 
               (result.description ? result.description.substring(0,40) : result.content.substring(0,40)) +
                '</div></div>';
          content.appendChild(item);
        });
      } else {
        var item = document.createElement('span');
        content.appendChild(item);
      }

      let wrap = document.getElementById('search-mobile-results');
      while (wrap.firstChild) {
        wrap.removeChild(wrap.firstChild)
      }
      searchResults.appendChild(content);      
    }

    function renderSearchHighlightResultsMobile(searchText, results) {
      searchResults = document.getElementById('search-mobile-results');

      var ul = document.createElement('div');
      ul.setAttribute('class', 'mobile-search__content');

      if (results.length) {
        results.forEach(function (result) {
          var li = document.createElement('li');
          var a = document.createElement('a');
          var descDiv = null;

          a.setAttribute('href', result.item.uri);
          a.appendChild(li);
          li.setAttribute('class', 'mobile-search__item');

          var titleDiv = document.createElement('div');
          titleDiv.innerHTML = result.item.title;
          titleDiv.setAttribute('class', 'mobile-search__item--title');
          
          if (result.matches && result.matches.length) {
            for (var i = 0; i < result.matches.length; i++) {
              if ('title' === result.matches[i].key) {
                titleDiv.innerHTML = generateHighlightedText(result.matches[i].value, result.matches[i].indices);
              }

              if ('description' === result.matches[i].key) {
                descDiv = document.createElement('div');
                descDiv.setAttribute('class', 'mobile-search__item--desc');
                descDiv.innerHTML = generateHighlightedText(result.item.description, result.matches[i].indices);
              } else if ('content' === result.matches[i].key) {
                if (!descDiv) {
                  descDiv = document.createElement('div');
                  descDiv.setAttribute('class', 'mobile-search__item--desc');
                  descDiv.innerHTML = generateHighlightedText(result.item.content.substring(0, 150), result.matches[i].indices);
                }
              } else {
                if (result.item.description) {
                  descDiv = document.createElement('div');
                  descDiv.setAttribute('class', 'mobile-search__item--desc');
                  descDiv.innerHTML = result.item.description;
                } else {
                  descDiv = document.createElement('div');
                  descDiv.setAttribute('class', 'mobile-search__item--desc');
                  descDiv.innerHTML = result.item.content.substring(0, 150);
                }
              }
            }
            
            li.appendChild(titleDiv);
            if (descDiv) {
              li.appendChild(descDiv);
            }
            ul.appendChild(a);
          }
        });
      } else {
        var item = document.createElement('span');
        ul.appendChild(item);
      }

      let wrap = document.getElementById('search-mobile-results');
      while (wrap.firstChild) {
        wrap.removeChild(wrap.firstChild)
      }
      searchResults.appendChild(ul);
    }

    function generateHighlightedText(text, regions) {
      if (!regions) {
        return text;
      }

      var content = '', nextUnhighlightedRegionStartingIndex = 0;

      regions.forEach(function(region) {
        if (region[0] === region[1]) {
          return null;
        }
        
        content += '' +
          text.substring(nextUnhighlightedRegionStartingIndex, region[0]) +
          '<span class="search__highlight">' +
            text.substring(region[0], region[1] + 1) +
          '</span>' +
        '';
        nextUnhighlightedRegionStartingIndex = region[1] + 1;
      });

      content += text.substring(nextUnhighlightedRegionStartingIndex);

      return content;
    };

    var searchElem = document.getElementById('search');
    var searchMobile = document.getElementById('search-mobile');
    var searchResultsContainer = document.getElementById('search-results');

    searchElem ? 
    searchElem.addEventListener('input', function(e) {
      if (!e.target.value | window.innerWidth < 770) {
        searchResultsContainer ? searchResultsContainer.setAttribute('class', 'dd') : null;
        return null;
      }

      searchText = e.target.value;
      var results = fuse.search(e.target.value);

      if (enableSearchHighlight) {
        renderSearchHighlightResults(searchText, results);
      } else {
        renderSearchResults(searchText, results);
      }

      var dropdownItems = searchResultsContainer.querySelectorAll('.dd-item');
      dropdownItems ? dropdownItems.forEach(function (item) {
        item.addEventListener('mousedown', function (e) {
          e.target.click();
        });
      }) : null;
    }) : null;

    searchElem ? 
    searchElem.addEventListener('blur', function() {
      if (window.innerWidth < 770) {
        return null;
      }
      searchResultsContainer ? searchResultsContainer.setAttribute('class', 'dd') : null;
    }) : null;

    searchElem ? 
    searchElem.addEventListener('click', function(e) {
      if (window.innerWidth < 770) {
        return null;
      }
      if (!e.target.value) {
        searchResultsContainer ? searchResultsContainer.setAttribute('class', 'dd') : null;
        return null;
      }

      searchText = e.target.value;
      var results = fuse.search(e.target.value);

      if (enableSearchHighlight) {
        renderSearchHighlightResults(searchText, results);
      } else {
        renderSearchResults(searchText, results);
      }

      var dropdownItems = searchResultsContainer.querySelectorAll('.dd-item');
      dropdownItems ? dropdownItems.forEach(function (item) {
        item.addEventListener('mousedown', function (e) {
          e.target.click();
        });
      }) : null;
    }) : null;

    var searchMenuElem = document.getElementById("search-menu");
    var activeItem = document.querySelector('#search-menu .dd-item.is-active');
    var activeIndex = null;
    var items = null;
    var searchContainerMaxHeight = 350;

    searchElem ? 
    searchElem.addEventListener('keydown', function(e) {
      if (window.innerWidth < 770) {
        return null;
      }

      var items = document.querySelectorAll('#search-menu .dd-item');
      
      if (e.key === 'ArrowDown') {
        if (activeIndex === null) {
          activeIndex = 0;
          items[activeIndex].classList.remove('is-active');
        } else {
          items[activeIndex].classList.remove('is-active');
          activeIndex = activeIndex === items.length - 1 ? 0 : activeIndex + 1;
        }
        items[activeIndex].classList.add('is-active');

        let overflowedPixel = items[activeIndex].offsetTop + items[activeIndex].clientHeight - searchContainerMaxHeight;
        if (overflowedPixel > 0) {
          document.querySelector(".search-content").scrollTop += items[activeIndex].getBoundingClientRect().height;
        } else if (activeIndex === 0) {
          document.querySelector(".search-content").scrollTop = 0;
        }
      } else if (e.key === 'ArrowUp') {
        if (activeIndex === null) {
          activeIndex = items.length - 1;
          items[activeIndex].classList.remove('is-active');
        } else {
          items[activeIndex].classList.remove('is-active');
          activeIndex = activeIndex === 0 ? items.length - 1 : activeIndex - 1;
        }
        items[activeIndex].classList.add('is-active');
        
        let overflowedPixel = items[activeIndex].offsetTop + items[activeIndex].clientHeight - searchContainerMaxHeight;
        if (overflowedPixel < 0) {
          document.querySelector(".search-content").scrollTop -= items[activeIndex].getBoundingClientRect().height;
        } else {
          document.querySelector(".search-content").scrollTop = overflowedPixel + items[activeIndex].getBoundingClientRect().height;
        }
      } else if (e.key === 'Enter') {
        var currentItemLink = items[activeIndex].getAttribute('href');
        if (currentItemLink) {
          location.href = currentItemLink;
        }
      } else if (e.key === 'Escape') {
        e.target.value = null;
        if (searchResults) {
          searchResults.classList.remove('is-active');
        }
      }
    }) : null;

    searchMobile ? 
    searchMobile.addEventListener('input', function(e) {
      if (!e.target.value) {
        let wrap = document.getElementById('search-mobile-results');
        while (wrap.firstChild) {
          wrap.removeChild(wrap.firstChild);
        }
        return null;
      }

      searchText = e.target.value;
      var results = fuse.search(e.target.value);
      
      if (enableSearchHighlight) {
        renderSearchHighlightResultsMobile(searchText, results);
      } else {
        renderSearchResultsMobile(searchText, results);
      }

      var dropdownItems = searchResultsContainer.querySelectorAll('.dd-item');
      dropdownItems ? dropdownItems.forEach(function (item) {
        item.addEventListener('mousedown', function (e) {
          e.target.click();
        });
      }) : null;
    }) : null;
  
  }
</script>
    


<link rel="stylesheet" href="/css/main.min.css">


    <meta name="description" content="" />
<meta name="keywords" content="">
<meta name="created" content="2020-01-05T22:51:52&#43;0800">
<meta name="modified" content="2020-02-28T11:19:00&#43;0800">
<meta name="author" content="峰峰">

<meta property="og:site_name" content="邵晨峰的博客">
<meta property="og:title" content="C语言标准库stdlib">
<meta property="og:url" content="http://shaochenfeng.com/blog/c%E8%AF%AD%E8%A8%80%E6%A0%87%E5%87%86%E5%BA%93stdlib.h%E5%AD%A6%E4%B9%A0/">
<meta property="og:type" content="article">
<meta property="og:image" content="http://shaochenfeng.com/me/pic1.jpg">
<meta name="generator" content="Hugo 0.81.0" />
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="theme-color" content="#ffffff">
<link rel="canonical" href="http://shaochenfeng.com/blog/c%E8%AF%AD%E8%A8%80%E6%A0%87%E5%87%86%E5%BA%93stdlib.h%E5%AD%A6%E4%B9%A0/">
<link rel="manifest" href="/manifest.json">

  <link rel="apple-touch-icon" sizes="57x57" href="/favicon/apple-icon-57x57.png">
  <link rel="apple-touch-icon" sizes="60x60" href="/favicon/apple-icon-60x60.png">
  <link rel="apple-touch-icon" sizes="72x72" href="/favicon/apple-icon-72x72.png">
  <link rel="apple-touch-icon" sizes="76x76" href="/favicon/apple-icon-76x76.png">
  <link rel="apple-touch-icon" sizes="114x114" href="/favicon/apple-icon-114x114.png">
  <link rel="apple-touch-icon" sizes="120x120" href="/favicon/apple-icon-120x120.png">
  <link rel="apple-touch-icon" sizes="144x144" href="/favicon/apple-icon-144x144.png">
  <link rel="apple-touch-icon" sizes="152x152" href="/favicon/apple-icon-152x152.png">
  <link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-icon-180x180.png">
  <link rel="icon" type="image/png" sizes="192x192" href="/favicon/android-icon-192x192.png">
  <link rel="icon" type="image/png" sizes="192x192" href="/favicon/android-icon-512x512.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png">
  <link rel="icon" type="image/png" sizes="96x96" href="/favicon/favicon-96x96.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/favicon/favicon-16x16.png">
  <meta name="msapplication-TileColor" content="#ffffff">
  <meta name="msapplication-TileImage" content="/ms-icon-144x144.png">

    <script type="application/ld+json">
  {
    "@context": "https://schema.org",
    "@type": "BlogPosting",
    "headline": "C语言标准库stdlib",
    "datePublished": "2020-01-05T22:51:52+08:00",
    "dateModified": "2020-02-28T11:19:00+08:00",
    "url" : "http://shaochenfeng.com/blog/c%E8%AF%AD%E8%A8%80%E6%A0%87%E5%87%86%E5%BA%93stdlib.h%E5%AD%A6%E4%B9%A0/",
    "description": "\u003cp\u003e本文将介绍 C语言标准库\u0026lt;stdlib.h\u0026gt; 中的 宏、函数、数据类型\u003cbr /\u003e 在最后给出一个实例程序，尽可能运用到所有函数\u003c/p\u003e",
    "keywords": ["标准库","c/c++"],
    "image" : "http://shaochenfeng.com/me/pic1.jpg",
    "author": {
      "@type": "Person",
      "name": "峰峰"
    },
    "mainEntityOfPage": {
      "@type": "WebPage",
      "@id": "http://shaochenfeng.com"
    },
    "publisher": {
      "@type": "Organization",
      "name": "邵晨峰的博客",
      "url": "http://shaochenfeng.com"
    }
  }
</script>

    
<script>

var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?bbd1a2ff6319307f954c5233f13dcc26";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(hm, s);
})();
var _mtac = {};
(function() {
	var mta = document.createElement("script");
	mta.src = "//pingjs.qq.com/h5/stats.js?v2.0.4";
	mta.setAttribute("name", "MTAH5");
	mta.setAttribute("sid", "500711551");
	var s = document.getElementsByTagName("script")[0];
	s.parentNode.insertBefore(mta, s);
})();
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>

</head>


<body id="root" class="theme__light">
    <script>
        var rootElem = document.getElementById('root');
        var themeOptions = JSON.parse("[\"light\",\"dark\"]");
        var localTheme = localStorage.getItem('theme');

        if (localTheme) {
            if (themeOptions && themeOptions.length > 0) {
                themeOptions.includes(localTheme) ? 
                rootElem.className = `theme__${localTheme}` :
                rootElem.className = `theme__${themeOptions[0]}`;
            }
        }
    </script>
    
    <div id="container">
        <div id="myDrawer" class="drawer" style="">
  <div class="drawer__header">
    <a href="/" class="drawer__header--text">
      邵晨峰的博客
    </a>
    <div class="grow"></div>
    <div class="drawer__close">
      <svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0V0z"/><path fill="currentColor" d="M18.3 5.71c-.39-.39-1.02-.39-1.41 0L12 10.59 7.11 5.7c-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.02 0 1.41L10.59 12 5.7 16.89c-.39.39-.39 1.02 0 1.41.39.39 1.02.39 1.41 0L12 13.41l4.89 4.89c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4z"/></svg>
    </div>
  </div>

  <div class="drawer__body">
    <div class="menu">
  <h6 class="menu__label">
    
    
      C语言标准库stdlib
    
  </h6>
  <ul>
    
    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/camunda-springboot%E4%B8%8E%E8%BF%9B%E9%98%B6%E5%86%85%E5%AE%B9/"
      class="menu__title ">Camunda SpringBoot与进阶内容</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/camunda-%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8/"
      class="menu__title ">Camunda 快速入门</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/%E6%BA%90%E7%A0%81%E5%AE%89%E8%A3%85%E6%96%B9%E5%BC%8Fcentos7_nginx_php7.3/"
      class="menu__title ">源码安装方式 centos7 nginx php7.3</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/javaexecutor%E7%BA%BF%E7%A8%8B%E6%B1%A0%E6%A1%88%E4%BE%8B/"
      class="menu__title ">javaExecutor线程池案例</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/java%E9%81%8D%E5%8E%86%E6%95%B0%E7%BB%84listsetmap%E7%9A%84%E7%A7%8D%E7%A7%8D%E6%96%B9%E6%B3%95/"
      class="menu__title ">Java遍历数组、List、Set、Map的种种方法</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/java%E6%96%87%E4%BB%B6%E7%9A%84%E8%AF%BB%E5%86%99%E9%81%8D%E5%8E%86/"
      class="menu__title ">Java各种文件的读写和文件夹遍历方法</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/vsftpd%E6%90%AD%E5%BB%BAftp/"
      class="menu__title ">vsftpd搭建ftp</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/java-%E8%AF%BB%E5%86%99gbk%E7%BC%96%E7%A0%81%E7%9A%84%E6%96%87%E4%BB%B6/"
      class="menu__title ">Java 读写GBK编码的文件</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/%E7%94%A8%E5%91%BD%E4%BB%A4%E8%A1%8C%E6%9E%84%E5%BB%BA%E8%BF%90%E8%A1%8Cspringboot%E9%A1%B9%E7%9B%AE/"
      class="menu__title ">用命令行构建和运行springboot项目</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/%E5%86%99%E7%BB%99%E5%A4%A7%E5%BF%99%E4%BA%BA%E7%9C%8B%E7%9A%84git%E6%A1%88%E4%BE%8B%E6%80%BB%E7%BB%93/"
      class="menu__title ">写给大忙人看的Git案例总结</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/cento8%E5%AE%89%E8%A3%85szabbix%E7%9B%91%E6%8E%A7/"
      class="menu__title ">Centos8安装zabbix监控，源码方式</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/rpm%E5%B0%81%E8%A3%85%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AArpm%E5%8C%85%E7%9A%84%E7%AE%80%E5%8C%96%E6%8C%87%E5%8D%97/"
      class="menu__title ">RPM封装：创建一个RPM包的简化指南</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/firewall%E5%B8%B8%E7%94%A8%E8%A7%84%E5%88%99%E8%AE%BE%E7%BD%AE/"
      class="menu__title ">Firewall常用规则设置【转发】</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/2020%E5%B9%B4spring%E6%89%80%E6%9C%89%E5%AE%98%E6%96%B9%E9%A1%B9%E7%9B%AE%E4%BB%8B%E7%BB%8D/"
      class="menu__title ">2020年Spring所有官方项目介绍</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/%E5%88%9D%E6%8E%A2%E7%94%A8nginx-rtmp-module%E8%87%AA%E5%BB%BA%E7%9B%B4%E6%92%AD%E6%9C%8D%E5%8A%A1%E5%99%A8/"
      class="menu__title ">初探用nginx Rtmp Module自建直播服务器</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/supervisor-%E5%AE%88%E6%8A%A4%E8%BF%9B%E7%A8%8B%E5%B7%A5%E5%85%B7%E8%BD%AC%E8%BD%BD/"
      class="menu__title ">Supervisor-守护进程工具【转载】</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/apache_httpd%E5%92%8Cphp/"
      class="menu__title ">Apache httpd结合php，yum方式和源码方式</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/centos87%E5%AE%89%E8%A3%85tomcat9%E5%92%8C%E5%B8%B8%E8%A7%81%E7%94%A8%E6%B3%95/"
      class="menu__title ">Centos8(7)安装tomcat9和常见用法</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/yum%E5%AE%89%E8%A3%85httpdapache%E5%B9%B6%E8%AE%BE%E7%BD%AE%E8%99%9A%E6%8B%9F%E4%B8%BB%E6%9C%BA/"
      class="menu__title ">Yum安装httpd(apache)并设置虚拟主机</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/%E6%BA%90%E7%A0%81%E5%AE%89%E8%A3%85nginx%E5%88%B0%E6%8C%87%E5%AE%9A%E7%9B%AE%E5%BD%95/"
      class="menu__title ">源码安装nginx到指定目录</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/nginx%E9%85%8D%E7%BD%AEssl%E8%AF%81%E4%B9%A6%E6%94%AF%E6%8C%81htts/"
      class="menu__title ">Nginx配置ssl证书，支持https</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/yum%E5%AE%89%E8%A3%85mysql5.7%E6%9F%A5%E7%9C%8B%E9%BB%98%E8%AE%A4root%E5%AF%86%E7%A0%81/"
      class="menu__title ">yum安装mysql5.7，查看默认root密码</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/yum%E5%AE%89%E8%A3%85mysql8%E6%9F%A5%E7%9C%8B%E9%BB%98%E8%AE%A4root%E5%AF%86%E7%A0%81/"
      class="menu__title ">yum安装mysql8，查看默认root密码</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/sed%E5%B8%B8%E7%94%A8%E6%A8%A1%E6%9D%BF%E6%95%B4%E7%90%86/"
      class="menu__title ">sed常用模板整理</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/nginx%E7%AB%AF%E5%8F%A3%E8%BD%AC%E5%8F%91%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86/"
      class="menu__title ">Nginx端口转发（反向代理）</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/%E7%94%A8rsync%E5%AE%9E%E7%8E%B0%E7%BD%91%E7%AB%99%E7%9A%84%E5%A2%9E%E9%87%8F%E9%83%A8%E7%BD%B2/"
      class="menu__title ">用Rsync,实现网站的增量部署</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/%E7%BA%A2%E5%B8%BD8%E5%8F%91%E8%A1%8C%E7%89%88%E8%AF%B4%E6%98%8Epdf/"
      class="menu__title ">红帽8发行版说明PDF</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/2020%E5%B9%B4centos87%E6%9B%B4%E6%8D%A2yum%E6%BA%90%E4%B8%BA%E9%98%BF%E9%87%8C%E6%BA%90/"
      class="menu__title ">2020年CentOS8(7)更换yum源为阿里源</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/centos8yum%E5%AE%89%E8%A3%85nginx%E5%B9%B6%E8%AE%BE%E7%BD%AE%E8%99%9A%E6%8B%9F%E4%B8%BB%E6%9C%BA/"
      class="menu__title ">Centos8 Yum安装nginx并设置虚拟主机</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="active">
    <a href="http://shaochenfeng.com/blog/c%E8%AF%AD%E8%A8%80%E6%A0%87%E5%87%86%E5%BA%93stdlib.h%E5%AD%A6%E4%B9%A0/"
      class="menu__title active">C语言标准库stdlib</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/%E5%85%B3%E4%BA%8E%E6%88%91/"
      class="menu__title ">关于我</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/acme.sh/"
      class="menu__title ">使用acme.sh进行ssl申请和自动续约</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/markdown-syntax/"
      class="menu__title ">Markdown Syntax Guide</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/placeholder-text/"
      class="menu__title ">Placeholder Text</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/emoji-support/"
      class="menu__title ">Emoji Support</a>
  </li>
  

    
      
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  <li class="">
    <a href="http://shaochenfeng.com/blog/nuklear%E7%9A%84%E8%AE%BE%E8%AE%A1%E4%B8%8E%E6%BA%90%E7%A0%81%E5%88%86%E6%9E%90/"
      class="menu__title ">nuklear的设计与源码分析</a>
  </li>
  

    
  </ul>
</div>



<script>
  var menuTitle = document.querySelectorAll('.menu__title');
  var modal = document.getElementById("myModal");
  var drawer = document.getElementById('myDrawer');

  var closeDrawer = function () {
    setTimeout(function () {
      modal.style.opacity = 0;
      drawer.style.left = '-100%';
      modal.style.left = '-100%';
    }, 250);
  }

  menuTitle ? 
  menuTitle.forEach(function(elem) {
    elem.onclick = function() {
      closeDrawer();
      localStorage.setItem('isDrawerOpen', 'false');
    }
  }) : null;
</script>
  </div>
</div>
<div id="myModal" class="modal" style=""></div>

<script>
  var isDrawerOpen = localStorage.getItem('isDrawerOpen');
  var modal = document.getElementById("myModal");
  var drawer = document.getElementById('myDrawer');
  
  
  var languagedir = JSON.parse("\"ltr\"");

  var openDrawer = function () {
    modal.style.opacity = 1;
    
    if (languagedir === "rtl") {
      modal.style.right = 0;
      drawer.style.right = 0;
    } else {
      modal.style.left = 0;
      drawer.style.left = 0;
    }
  }

  if (isDrawerOpen && isDrawerOpen === 'true') {
    openDrawer();
  }
</script>
        
<nav class="nav">
  <div class="navbar__wrapper" data-bgimg="false">
    <div class="divider">
      <div class="navbar lmr">
        <div id="siteLogo" class="navbar__logo--wrapper">
  
    <a href="/" title="" rel="home" class="navbar__logo--link">
      <img src="/logo.png" alt="Home" class="navbar__logo">
    </a>
  
  
    <a href="/" title="" rel="home" class="navbar__logo--text-link">
      <h6 class="navbar__logo--text" data-bgimg="false">邵晨峰的博客</h6>
    </a>
  
</div>
        
        <div class="navbar__menu--wrapper">
          <div id="tabletLogo" class="hide">
  
  <a href="/" rel="home" class="navbar__logo--link">
    <img src="/logo.png" alt="Home" class="navbar__logo">
  </a>
  
</div>
          <div id="mobileLogo" class="hide">
  <a href="#" class="navbar__logo--link">
    <div class="navbar__icons--icon">
      <svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0V0z"/><path fill="currentColor" d="M4 18h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm0-5h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zM3 7c0 .55.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1z"/></svg>
    </div>
  </a>
</div>
          <span id="navMenuMobile" class="hide">
  <button id="navCollapseBtn" class="navbar__dropdown--title" aria-label="Section Menu" data-dir="ltr">
    
      blog
    
    <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24"><path fill="currentColor" d="M8.12 9.29L12 13.17l3.88-3.88c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41l-4.59 4.59c-.39.39-1.02.39-1.41 0L6.7 10.7c-.39-.39-.39-1.02 0-1.41.39-.38 1.03-.39 1.42 0z"/></svg>
  </button>
  <div class="navbar__collapse" data-open="false">
  <ul>
    

  
  
  
  
  <li class="navbar__menu--mobile-item active">
    <a href="/blog" class="active">博客</a>
  </li>

  
  
  
  
  <li class="navbar__menu--mobile-item ">
    <a href="/linux" class="">linux运维</a>
  </li>

  
  
  
  
  <li class="navbar__menu--mobile-item ">
    <a href="/camunda" class="">camunda流程引擎</a>
  </li>

  
  
  
  
  <li class="navbar__menu--mobile-item ">
    <a href="/camunda-cn" class="">camunda中文站</a>
  </li>

  </ul>
</div>
</span>
          <ul id="navMenu" class="navbar__menu">
            

  
  
  
  
  <li class="navbar__menu--item active">
    <a href="/blog" data-bgimg="false">博客</a>
  </li>

  
  
  
  
  <li class="navbar__menu--item ">
    <a href="/linux" data-bgimg="false">linux运维</a>
  </li>

  
  
  
  
  <li class="navbar__menu--item ">
    <a href="/camunda" data-bgimg="false">camunda流程引擎</a>
  </li>

  
  
  
  
  <li class="navbar__menu--item ">
    <a href="/camunda-cn" data-bgimg="false">camunda中文站</a>
  </li>

          </ul>
        </div>
        <div class="grow"></div>
        <div id="siteSearch">
          

<div class="search" data-bgimg="false">
  <span class="icon">
    <svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" fill="currentColor" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0V0z"/><path d="M15.5 14h-.79l-.28-.27c1.2-1.4 1.82-3.31 1.48-5.34-.47-2.78-2.79-5-5.59-5.34-4.23-.52-7.79 3.04-7.27 7.27.34 2.8 2.56 5.12 5.34 5.59 2.03.34 3.94-.28 5.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>
  </span>
  <input id="search" aria-label="Site Search" class="input" type="text" autocomplete="no" onkeydown="baiduSearch(event);" placeholder="搜索">
  <div id="search-results" class="dropdown">
    <div id="search-menu" class="dropdown-menu">
    </div>
  </div>
</div>



        </div>
        <div id="mobileSearch" class="hide">
          
<div id="mobileSearchBtn" class="mobile-search__btn">
  <svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" fill="currentColor" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0V0z"/><path d="M15.5 14h-.79l-.28-.27c1.2-1.4 1.82-3.31 1.48-5.34-.47-2.78-2.79-5-5.59-5.34-4.23-.52-7.79 3.04-7.27 7.27.34 2.8 2.56 5.12 5.34 5.59 2.03.34 3.94-.28 5.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>
</div>

<div id="search-mobile-container" class="mobile-search hide">
  <div class="mobile-search__top">
    <input id="search-mobile" type="text" aria-label="Mobile Search" placeholder="Search..." class="mobile-search__top--input"/>
    <div id="search-mobile-close" class="mobile-search__top--icon">
      <svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24"><path opacity=".87" fill="none" d="M0 0h24v24H0V0z"/><path fill="currentColor" d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm3.59-13L12 10.59 8.41 7 7 8.41 10.59 12 7 15.59 8.41 17 12 13.41 15.59 17 17 15.59 13.41 12 17 8.41z"/></svg>
    </div>
  </div>
  <div id="search-mobile-results" class="mobile-search__body">
    
  </div>
</div>

        </div>
        <div class="navbar__icons">
  
  
<button id="toggleToDark" class="navbar__icons--icon" aria-label="Toggle to dark mode">
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12zm0-2a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM11 1h2v3h-2V1zm0 19h2v3h-2v-3zM3.515 4.929l1.414-1.414L7.05 5.636 5.636 7.05 3.515 4.93zM16.95 18.364l1.414-1.414 2.121 2.121-1.414 1.414-2.121-2.121zm2.121-14.85l1.414 1.415-2.121 2.121-1.414-1.414 2.121-2.121zM5.636 16.95l1.414 1.414-2.121 2.121-1.414-1.414 2.121-2.121zM23 11v2h-3v-2h3zM4 11v2H1v-2h3z"/></svg>
</button>
<button id="toggleToLight" class="navbar__icons--icon" aria-label="Toggle to light mode">
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11.38 2.019a7.5 7.5 0 1 0 10.6 10.6C21.662 17.854 17.316 22 12.001 22 6.477 22 2 17.523 2 12c0-5.315 4.146-9.661 9.38-9.981z" fill="rgba(255,255,255,1)"/></svg>
</button>
<script>
  var theme = localStorage.getItem('theme');
  var toggleToLightBtn = document.getElementById('toggleToLight');
  var toggleToDarkBtn = document.getElementById('toggleToDark');

  if (theme && theme === 'dark') {
    toggleToLightBtn.className = 'navbar__icons--icon';
    toggleToDarkBtn.className = 'hide';
  } else {
    toggleToLightBtn.className = 'hide';
    toggleToDarkBtn.className = 'navbar__icons--icon';
  }
</script>

  
</div>


      </div>
    </div>
  </div>
</nav>

<script>
  var siteLogo = document.getElementById('siteLogo');
  var tabletLogo = document.getElementById('tabletLogo');
  var mobileLogo = document.getElementById('mobileLogo');
  var navMenu = document.getElementById('navMenu');
  var navMenuMobile = document.getElementById('navMenuMobile');
  var siteSearch = document.getElementById('siteSearch');
  var mobileSearch = document.getElementById('mobileSearch');
  
  enquire.register("screen and (max-width:1280px)", {
    match: function () {
      siteLogo.className = 'navbar__logo--wrapper';
      tabletLogo.className = 'hide';
      mobileLogo.className = 'hide';
      navMenu.className = 'navbar__menu';
      navMenuMobile.className = 'hide';
      siteSearch.className = '';
      mobileSearch.className = 'hide';
    },
    unmatch: function () {
      siteLogo.className = 'navbar__logo--wrapper';
      tabletLogo.className = 'hide';
      mobileLogo.className = 'hide';
      navMenu.className = 'navbar__menu';
      navMenuMobile.className = 'hide';
      siteSearch.className = '';
      mobileSearch.className = 'hide';
    },
  }).register("screen and (max-width:960px)", {
    match: function () {
      siteLogo.className = 'hide';
      tabletLogo.className = '';
      mobileLogo.className = 'hide';
      navMenu.className = 'navbar__menu';
      navMenuMobile.className = 'hide';
      siteSearch.className = 'hide';
      mobileSearch.className = 'navbar__icons--icon';
    },
    unmatch: function () {
      siteLogo.className = 'navbar__logo--wrapper';
      tabletLogo.className = 'hide';
      mobileLogo.className = 'hide';
      navMenu.className = 'navbar__menu';
      navMenuMobile.className = 'hide';
      siteSearch.className = '';
      mobileSearch.className = 'hide';
    },
  }).register("screen and (max-width:600px)", {
    match: function () {
      siteLogo.className = 'hide';
      tabletLogo.className = 'hide';
      mobileLogo.className = '';
      navMenu.className = 'hide';
      navMenuMobile.className = '';
      siteSearch.className = 'hide';
      mobileSearch.className = 'navbar__icons--icon';
    },
    unmatch: function () {
      siteLogo.className = 'hide';
      tabletLogo.className = '';
      mobileLogo.className = 'hide';
      navMenu.className = 'navbar__menu';
      navMenuMobile.className = 'hide';
      siteSearch.className = 'hide';
      mobileSearch.className = 'navbar__icons--icon';
    },
  });
</script>

        
        

<div class="mid">
  <div class="divider">
    
    <nav id="single-menu" class="l" data-dir="ltr">
    </nav>

    <article id="list-main" class="m" data-dir="ltr">
      
      <div class="single" data-display="block">
  
    <div class="single__title">
      C语言标准库stdlib
    </div>
    <div class="single__meta">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" fill="currentColor"><path d="M4 4H20V8H4z" opacity=".3"/><path d="M6 1H8V5H6zM16 1H18V5H16z"/><path d="M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M19,19H5V9h14V19z M19,7H5V5h14V7z"/></svg><time title="创建于">2020年1月5日 </time> &nbsp;&nbsp; <svg fill="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="currentColor" d="M 9 1 L 9 3 L 15 3 L 15 1 L 9 1 z M 18.958984 2.7929688 L 17.666016 4.3183594 L 20.615234 6.8183594 L 21.908203 5.2929688 L 18.958984 2.7929688 z M 12 4 C 7.0225467 4 3 8.0225467 3 13 C 3 17.977453 7.0225467 22 12 22 C 16.977453 22 21 17.977453 21 13 C 21 8.0225467 16.977453 4 12 4 z M 12 6 C 15.910547 6 19 9.0894533 19 13 C 19 16.910547 15.910547 20 12 20 C 8.0894533 20 5 16.910547 5 13 C 5 9.0894533 8.0894533 6 12 6 z M 11 8 L 11 14 L 13 14 L 13 8 L 11 8 z"/></svg> <span title="阅读时间"> 5 分钟阅读</span> &nbsp;&nbsp; <svg fill="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="16" height="16"><path fill="currentColor" d="M 16 5 C 12.144531 5 9 8.144531 9 12 C 9 14.410156 10.230469 16.550781 12.09375 17.8125 C 8.527344 19.34375 6 22.882813 6 27 L 8 27 C 8 22.570313 11.570313 19 16 19 C 20.429688 19 24 22.570313 24 27 L 26 27 C 26 22.882813 23.472656 19.34375 19.90625 17.8125 C 21.769531 16.550781 23 14.410156 23 12 C 23 8.144531 19.855469 5 16 5 Z M 16 7 C 18.773438 7 21 9.226563 21 12 C 21 14.773438 18.773438 17 16 17 C 13.226563 17 11 14.773438 11 12 C 11 9.226563 13.226563 7 16 7 Z"/></svg> <span title="作者：">峰峰</span>
    </div>
  
  <article class="single__contents" data-dir="ltr">
    <h1 class="title" style="border-bottom: 1px solid currentColor">C语言标准库stdlib</h1>
    <p>本文将介绍 C语言标准库&lt;stdlib.h&gt; 中的 宏、函数、数据类型<br />
在最后给出一个实例程序，尽可能运用到所有函数</p>
<h2 id="宏">宏</h2>
<h3 id="exit_success-和-exit_failure">EXIT_SUCCESS 和 EXIT_FAILURE</h3>
<p>exit函数成功退出和失败的返回值</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#099">#define EXIT_SUCCESS	0
</span><span style="color:#099">#define EXIT_FAILURE	1
</span></code></pre></div><h3 id="rand_max-rand-函数返回的最大的数">RAND_MAX rand 函数返回的最大的数</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#099">#define RAND_MAX	0x7FFF
</span></code></pre></div><h3 id="mb_cur_max-一个多字节字符的最大字节数">MB_CUR_MAX 一个多字节字符的最大字节数</h3>
<p>源码处理的比较复杂</p>
<h2 id="函数">函数</h2>
<h3 id="将字符串转换为-double">将字符串转换为 double</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#078;font-weight:bold">double</span> <span style="color:#c0f">atof</span> (<span style="color:#069;font-weight:bold">const</span> <span style="color:#078;font-weight:bold">char</span> <span style="color:#555">*</span>);
</code></pre></div><h3 id="将字符串转换为-int">将字符串转换为 int</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#078;font-weight:bold">int</span> <span style="color:#c0f">atoi</span> (<span style="color:#069;font-weight:bold">const</span> <span style="color:#078;font-weight:bold">char</span> <span style="color:#555">*</span>);
</code></pre></div><h3 id="将字符串转换为-long-int">将字符串转换为 long int</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#078;font-weight:bold">long</span> <span style="color:#c0f">atol</span> (<span style="color:#069;font-weight:bold">const</span> <span style="color:#078;font-weight:bold">char</span> <span style="color:#555">*</span>);
</code></pre></div><h3 id="将以数字开头的字符串转换为-double">将以数字开头的字符串转换为 double</h3>
<p>str 是一个以数字开头的字符串，<br />
返回把 str 转换后的 double ， endptr 指向第一个不是数字的字符</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#078;font-weight:bold">double</span> strtod(<span style="color:#069;font-weight:bold">const</span> <span style="color:#078;font-weight:bold">char</span> <span style="color:#555">*</span>str, <span style="color:#078;font-weight:bold">char</span> <span style="color:#555">**</span>endptr)
</code></pre></div><h3 id="将以数字开头的字符串转换为-long-int">将以数字开头的字符串转换为 long int</h3>
<p>str 是一个以数字开头的字符串，<br />
返回把 str 以 base 为基数（进制）转换后的 long int ，<br />
endptr 指向第一个不是数字的字符</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#078;font-weight:bold">long</span> <span style="color:#078;font-weight:bold">int</span> strtol(<span style="color:#069;font-weight:bold">const</span> <span style="color:#078;font-weight:bold">char</span> <span style="color:#555">*</span>str, <span style="color:#078;font-weight:bold">char</span> <span style="color:#555">**</span>endptr, <span style="color:#078;font-weight:bold">int</span> base)
</code></pre></div><h3 id="str-是一个以数字开头的字符串">str 是一个以数字开头的字符串，</h3>
<p>返回把 str 以 base 为基数 转换后的 unsigned long int ，<br />
endptr 指向第一个不是数字的字符</p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#078;font-weight:bold">unsigned</span> <span style="color:#078;font-weight:bold">long</span> <span style="color:#078;font-weight:bold">int</span> strtoul(<span style="color:#069;font-weight:bold">const</span> <span style="color:#078;font-weight:bold">char</span> <span style="color:#555">*</span>str, <span style="color:#078;font-weight:bold">char</span> <span style="color:#555">**</span>endptr, <span style="color:#078;font-weight:bold">int</span> base)
</code></pre></div><h3 id="分配请求的内存大小nitems--size并返回指向它的指针">分配请求的内存大小(nitems * size)并返回指向它的指针</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#078;font-weight:bold">void</span> <span style="color:#555">*</span>calloc(size_t nitems, size_t size)
</code></pre></div><h3 id="分配请求的内存size并返回指向它的指针">分配请求的内存(size)并返回指向它的指针</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#078;font-weight:bold">void</span> <span style="color:#555">*</span>malloc(size_t size)
</code></pre></div><h3 id="调整之前分配的内存块大小">调整之前分配的内存块大小</h3>
<ul>
<li>ptr 执行要调整的内存块</li>
<li>size 要调整到的字节数</li>
</ul>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#078;font-weight:bold">void</span> <span style="color:#555">*</span>realloc(<span style="color:#078;font-weight:bold">void</span> <span style="color:#555">*</span>ptr, size_t size)
</code></pre></div><h3 id="回收先前分配的内存">回收先前分配的内存</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#078;font-weight:bold">void</span> free(<span style="color:#078;font-weight:bold">void</span> <span style="color:#555">*</span>ptr)
</code></pre></div><h3 id="搜索环境变量并返回字符串">搜索环境变量并返回字符串</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#078;font-weight:bold">char</span> <span style="color:#555">*</span>getenv(<span style="color:#069;font-weight:bold">const</span> <span style="color:#078;font-weight:bold">char</span> <span style="color:#555">*</span>name)
</code></pre></div><h3 id="把命令string传递给主机由主机执行">把命令(string)传递给主机由主机执行</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#078;font-weight:bold">int</span> system(<span style="color:#069;font-weight:bold">const</span> <span style="color:#078;font-weight:bold">char</span> <span style="color:#555">*</span>string)
</code></pre></div><h3 id="快速排序">快速排序</h3>
<ul>
<li>base是数组的基地址</li>
<li>nitems是数组的元素个数</li>
<li>size是数组元素大小</li>
<li>compar是比较函数，靠返回值正负来比较，为0的情况未定义</li>
</ul>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#078;font-weight:bold">void</span> qsort(<span style="color:#078;font-weight:bold">void</span> <span style="color:#555">*</span>base, size_t nitems, size_t size,
                <span style="color:#078;font-weight:bold">int</span> (<span style="color:#555">*</span>compar)(<span style="color:#069;font-weight:bold">const</span> <span style="color:#078;font-weight:bold">void</span> <span style="color:#555">*</span>, <span style="color:#069;font-weight:bold">const</span> <span style="color:#078;font-weight:bold">void</span><span style="color:#555">*</span>))
</code></pre></div><h3 id="二分查找">二分查找</h3>
<ul>
<li>key是要查找的元素</li>
<li>base是数组的基地址</li>
<li>num是数组的元素个数</li>
<li>size数组元素大小</li>
<li>cmp是比较函数，靠返回值正负来比较，数组必须是排好序的</li>
<li>返回找到的元素的指针</li>
</ul>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#078;font-weight:bold">void</span> <span style="color:#555">*</span><span style="color:#c0f">bsearch</span>(<span style="color:#069;font-weight:bold">const</span> <span style="color:#078;font-weight:bold">void</span> <span style="color:#555">*</span>key, <span style="color:#069;font-weight:bold">const</span> <span style="color:#078;font-weight:bold">void</span> <span style="color:#555">*</span>base, size_t num, size_t size,
                <span style="color:#078;font-weight:bold">int</span> (<span style="color:#555">*</span>cmp)(<span style="color:#069;font-weight:bold">const</span> <span style="color:#078;font-weight:bold">void</span> <span style="color:#555">*</span>, <span style="color:#069;font-weight:bold">const</span> <span style="color:#078;font-weight:bold">void</span> <span style="color:#555">*</span>));
</code></pre></div><h3 id="返回x的绝对值">返回x的绝对值</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#078;font-weight:bold">int</span> abs(<span style="color:#078;font-weight:bold">int</span> x)
<span style="color:#078;font-weight:bold">long</span> <span style="color:#078;font-weight:bold">int</span> labs(<span style="color:#078;font-weight:bold">long</span> <span style="color:#078;font-weight:bold">int</span> x)
</code></pre></div><h3 id="做除法分别得到除数和被除数">做除法，分别得到除数和被除数</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c">div_t div(<span style="color:#078;font-weight:bold">int</span> numer, <span style="color:#078;font-weight:bold">int</span> denom)
ldiv_t ldiv(<span style="color:#078;font-weight:bold">long</span> <span style="color:#078;font-weight:bold">int</span> numer, <span style="color:#078;font-weight:bold">long</span> <span style="color:#078;font-weight:bold">int</span> denom)
</code></pre></div><h3 id="返回一个随机数范围0rand_max">返回一个随机数，范围(0~RAND_MAX)</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#078;font-weight:bold">int</span> rand(<span style="color:#078;font-weight:bold">void</span>)
</code></pre></div><h3 id="对随机函数设置种子">对随机函数设置种子</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#078;font-weight:bold">void</span> srand(<span style="color:#078;font-weight:bold">unsigned</span> <span style="color:#078;font-weight:bold">int</span> seed)
</code></pre></div><h3 id="计算一个多字节字符的长度">计算一个多字节字符的长度</h3>
<ul>
<li>n 是多字节字符的长度的最大值</li>
</ul>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#078;font-weight:bold">int</span> mblen(<span style="color:#069;font-weight:bold">const</span> <span style="color:#078;font-weight:bold">char</span> <span style="color:#555">*</span>str, size_t n)
</code></pre></div><h3 id="多字节字符串转换为数组">多字节字符串转换为数组</h3>
<p>将由参数str指向的多字节字符串转换为由pwcs指向的数组</p>
<ul>
<li>n 是多字节字符的长度的最大值</li>
</ul>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c">size_t mbstowcs(schar_t <span style="color:#555">*</span>pwcs, <span style="color:#069;font-weight:bold">const</span> <span style="color:#078;font-weight:bold">char</span> <span style="color:#555">*</span>str, size_t n)
</code></pre></div><h3 id="在程序正常退出时执行">在程序正常退出时执行</h3>
<ul>
<li>func 要执行的函数</li>
</ul>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#078;font-weight:bold">int</span> atexit(<span style="color:#078;font-weight:bold">void</span> (<span style="color:#555">*</span>func)(<span style="color:#078;font-weight:bold">void</span>))
</code></pre></div><h3 id="程序异常退出">程序异常退出</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#078;font-weight:bold">void</span> abort(<span style="color:#078;font-weight:bold">void</span>)
</code></pre></div><h3 id="程序正常退出-返回给操作系统-status">程序正常退出 ,返回给操作系统 status</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#078;font-weight:bold">void</span> exit(<span style="color:#078;font-weight:bold">int</span> status)
</code></pre></div><h2 id="数据类型">数据类型</h2>
<h3 id="size_t是sizeof关键词的值无符号整形">size_t是sizeof关键词的值，无符号整形</h3>
<h3 id="wchar_t-宽字符类型">wchar_t 宽字符类型</h3>
<h3 id="div_t与ldiv_t结构体-作为-div-的返回值">div_t与ldiv_t结构体 作为 div 的返回值</h3>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#069;font-weight:bold">typedef</span> <span style="color:#069;font-weight:bold">struct</span> {
    <span style="color:#078;font-weight:bold">int</span> quot; <span style="color:#09f;font-style:italic">// 商
</span><span style="color:#09f;font-style:italic"></span>    <span style="color:#078;font-weight:bold">int</span> rem;  <span style="color:#09f;font-style:italic">// 余数
</span><span style="color:#09f;font-style:italic"></span>} div_t;
<span style="color:#09f;font-style:italic">//-------------------------------
</span><span style="color:#09f;font-style:italic"></span><span style="color:#069;font-weight:bold">typedef</span> <span style="color:#069;font-weight:bold">struct</span> {
    <span style="color:#078;font-weight:bold">long</span> <span style="color:#078;font-weight:bold">int</span> quot; <span style="color:#09f;font-style:italic">// 商
</span><span style="color:#09f;font-style:italic"></span>    <span style="color:#078;font-weight:bold">long</span> <span style="color:#078;font-weight:bold">int</span> rem;  <span style="color:#09f;font-style:italic">// 余数
</span><span style="color:#09f;font-style:italic"></span>} ldiv_t;
</code></pre></div><h2 id="示例文件">示例文件</h2>
<p><a href="https://github.com/zoollcar/stdlib_learn_note_chinese" target="_blank">Github</a></p>
<div class="highlight"><pre style="background-color:#f0f3f3;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c"><span style="color:#099">#include</span> <span style="color:#099">&lt;stdio.h&gt;</span><span style="color:#099">
</span><span style="color:#099">#include</span> <span style="color:#099">&lt;stdlib.h&gt;</span><span style="color:#099">
</span><span style="color:#099">#include</span> <span style="color:#099">&lt;string.h&gt;</span><span style="color:#099">
</span><span style="color:#099"></span><span style="color:#078;font-weight:bold">void</span> <span style="color:#c0f">test</span>(){ printf(<span style="color:#c30">&#34;do this at exit</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>); }
<span style="color:#078;font-weight:bold">int</span> <span style="color:#c0f">cmptest</span>(<span style="color:#069;font-weight:bold">const</span> <span style="color:#078;font-weight:bold">void</span> <span style="color:#555">*</span> a, <span style="color:#069;font-weight:bold">const</span> <span style="color:#078;font-weight:bold">void</span> <span style="color:#555">*</span> b){
    <span style="color:#069;font-weight:bold">return</span> (<span style="color:#078;font-weight:bold">int</span>)( <span style="color:#555">*</span>(<span style="color:#078;font-weight:bold">char</span><span style="color:#555">*</span>)a <span style="color:#555">-</span> <span style="color:#555">*</span>(<span style="color:#078;font-weight:bold">char</span><span style="color:#555">*</span>)b );
}
<span style="color:#078;font-weight:bold">int</span> <span style="color:#c0f">main</span> (){
<span style="color:#09f;font-style:italic">///
</span><span style="color:#09f;font-style:italic">/// ## 数据类型
</span><span style="color:#09f;font-style:italic">///
</span><span style="color:#09f;font-style:italic"></span> 
<span style="color:#09f;font-style:italic">/// ### size_t是sizeof关键词的值，无符号整形
</span><span style="color:#09f;font-style:italic"></span>    printf(<span style="color:#c30">&#34;size_t %d</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>,<span style="color:#069;font-weight:bold">sizeof</span>(size_t));
    
<span style="color:#09f;font-style:italic">/// ### wchar_t 宽字符类型
</span><span style="color:#09f;font-style:italic"></span>    printf(<span style="color:#c30">&#34;wchar_t %d</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>,<span style="color:#069;font-weight:bold">sizeof</span>(wchar_t));
    
    
<span style="color:#09f;font-style:italic">/// ### div_t与ldiv_t结构体 作为 div 的返回值
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// typedef struct {
</span><span style="color:#09f;font-style:italic">///     int quot; // 商
</span><span style="color:#09f;font-style:italic">///     int rem;  // 余数
</span><span style="color:#09f;font-style:italic">/// } div_t;
</span><span style="color:#09f;font-style:italic"></span>
    div_t div_t_timp;
    printf(<span style="color:#c30">&#34;div_t %d  div_t.quot %d div_t.rem %d</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>,
    <span style="color:#069;font-weight:bold">sizeof</span>(div_t),<span style="color:#069;font-weight:bold">sizeof</span>(div_t_timp.quot),<span style="color:#069;font-weight:bold">sizeof</span>(div_t_timp.rem));
<span style="color:#09f;font-style:italic">/// //-------------------------------
</span><span style="color:#09f;font-style:italic">/// typedef struct {
</span><span style="color:#09f;font-style:italic">///     long int quot; // 商
</span><span style="color:#09f;font-style:italic">///     long int rem;  // 余数
</span><span style="color:#09f;font-style:italic">/// } ldiv_t;
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    ldiv_t ldiv_t_timp;
    printf(<span style="color:#c30">&#34;ldiv_t %d  ldiv_t.quot %d ldiv_t.rem %d</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>,
    <span style="color:#069;font-weight:bold">sizeof</span>(ldiv_t),<span style="color:#069;font-weight:bold">sizeof</span>(ldiv_t_timp.quot),<span style="color:#069;font-weight:bold">sizeof</span>(ldiv_t_timp.rem));
    

<span style="color:#09f;font-style:italic">///
</span><span style="color:#09f;font-style:italic">/// ## 宏
</span><span style="color:#09f;font-style:italic">///
</span><span style="color:#09f;font-style:italic"></span>    
<span style="color:#09f;font-style:italic">/// ### EXIT_SUCCESS 和 EXIT_FAILURE
</span><span style="color:#09f;font-style:italic">/// exit函数成功退出和失败的返回值
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// #define EXIT_SUCCESS	0
</span><span style="color:#09f;font-style:italic">/// #define EXIT_FAILURE	1
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    printf(<span style="color:#c30">&#34;EXIT_SUCCESS %d</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">EXIT_FAILURE %d</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>,EXIT_SUCCESS,EXIT_FAILURE);
    
    
<span style="color:#09f;font-style:italic">/// ### RAND_MAX rand 函数返回的最大的数
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// #define RAND_MAX	0x7FFF
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    printf(<span style="color:#c30">&#34;RAND_MAX %d</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>,RAND_MAX);

    
<span style="color:#09f;font-style:italic">/// ### MB_CUR_MAX 一个多字节字符的最大字节数
</span><span style="color:#09f;font-style:italic">/// 头文件中的处理比较复杂
</span><span style="color:#09f;font-style:italic"></span>    printf(<span style="color:#c30">&#34;MB_CUR_MAX %d</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>,MB_CUR_MAX);
    
    
<span style="color:#09f;font-style:italic">///
</span><span style="color:#09f;font-style:italic">/// ## 函数
</span><span style="color:#09f;font-style:italic">///
</span><span style="color:#09f;font-style:italic"></span>    
<span style="color:#09f;font-style:italic">/// ### 将字符串转换为 double
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// double atof (const char *);
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    printf(<span style="color:#c30">&#34;atof(</span><span style="color:#c30;font-weight:bold">\&#34;</span><span style="color:#c30">12.3</span><span style="color:#c30;font-weight:bold">\&#34;</span><span style="color:#c30">) %f</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>,atof(<span style="color:#c30">&#34;12.3&#34;</span>));
    
<span style="color:#09f;font-style:italic">/// ### 将字符串转换为 int
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// int atoi (const char *);
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    printf(<span style="color:#c30">&#34;atoi(</span><span style="color:#c30;font-weight:bold">\&#34;</span><span style="color:#c30">12</span><span style="color:#c30;font-weight:bold">\&#34;</span><span style="color:#c30">) %d</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>,atoi(<span style="color:#c30">&#34;12&#34;</span>));
    
<span style="color:#09f;font-style:italic">/// ### 将字符串转换为 long int
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// long atol (const char *);
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    printf(<span style="color:#c30">&#34;atol(</span><span style="color:#c30;font-weight:bold">\&#34;</span><span style="color:#c30">123456789</span><span style="color:#c30;font-weight:bold">\&#34;</span><span style="color:#c30">) %ld</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>,atol(<span style="color:#c30">&#34;123456789&#34;</span>));
    
<span style="color:#09f;font-style:italic">/// ### 将以数字开头的字符串转换为 double
</span><span style="color:#09f;font-style:italic">/// str 是一个以数字开头的字符串，
</span><span style="color:#09f;font-style:italic">/// 返回把 str 转换后的 double ， endptr 指向第一个不是数字的字符
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// double strtod(const char *str, char **endptr)
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    <span style="color:#078;font-weight:bold">char</span> <span style="color:#555">*</span>p;
    printf(<span style="color:#c30">&#34;strtod(</span><span style="color:#c30;font-weight:bold">\&#34;</span><span style="color:#c30">12.030 hello</span><span style="color:#c30;font-weight:bold">\&#34;</span><span style="color:#c30">,&amp;p) %f&#34;</span>,strtod(<span style="color:#c30">&#34;12.030hello&#34;</span>,<span style="color:#555">&amp;</span>p));
    printf(<span style="color:#c30">&#34; %s</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>,p);
    
<span style="color:#09f;font-style:italic">/// ### 将以数字开头的字符串转换为 long int
</span><span style="color:#09f;font-style:italic">/// str 是一个以数字开头的字符串，
</span><span style="color:#09f;font-style:italic">/// 返回把 str 以 base 为基数（进制）转换后的 long int ，
</span><span style="color:#09f;font-style:italic">/// endptr 指向第一个不是数字的字符
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// long int strtol(const char *str, char **endptr, int base)
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    printf(<span style="color:#c30">&#34;strtol(</span><span style="color:#c30;font-weight:bold">\&#34;</span><span style="color:#c30">ffhello</span><span style="color:#c30;font-weight:bold">\&#34;</span><span style="color:#c30">,&amp;p,16) %ld&#34;</span>,strtol(<span style="color:#c30">&#34;ffhello&#34;</span>,<span style="color:#555">&amp;</span>p,<span style="color:#f60">16</span>));
    printf(<span style="color:#c30">&#34; %s</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>,p);
    
<span style="color:#09f;font-style:italic">/// ### str 是一个以数字开头的字符串，
</span><span style="color:#09f;font-style:italic">/// 返回把 str 以 base 为基数 转换后的 unsigned long int ，
</span><span style="color:#09f;font-style:italic">/// endptr 指向第一个不是数字的字符
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// unsigned long int strtoul(const char *str, char **endptr, int base)
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    printf(<span style="color:#c30">&#34;strtoul(</span><span style="color:#c30;font-weight:bold">\&#34;</span><span style="color:#c30">ffhello</span><span style="color:#c30;font-weight:bold">\&#34;</span><span style="color:#c30">,&amp;p,16) %uld&#34;</span>,strtoul(<span style="color:#c30">&#34;ffhello&#34;</span>,<span style="color:#555">&amp;</span>p,<span style="color:#f60">16</span>));
    printf(<span style="color:#c30">&#34; %s</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>,p);
    
<span style="color:#09f;font-style:italic">/// ### 分配请求的内存大小(nitems * size)并返回指向它的指针
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// void *calloc(size_t nitems, size_t size)
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    p <span style="color:#555">=</span> (<span style="color:#078;font-weight:bold">char</span> <span style="color:#555">*</span>)calloc(<span style="color:#f60">5</span>, <span style="color:#069;font-weight:bold">sizeof</span>(<span style="color:#078;font-weight:bold">char</span>));
    printf(<span style="color:#c30">&#34;calloc(5, sizeof(char))  %p</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>,p);
    
<span style="color:#09f;font-style:italic">/// ### 分配请求的内存(size)并返回指向它的指针
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// void *malloc(size_t size)
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    <span style="color:#09f;font-style:italic">/* p = (char *)calloc(5 * sizeof(char)); */</span>
    
<span style="color:#09f;font-style:italic">/// ### 调整之前分配的内存块大小
</span><span style="color:#09f;font-style:italic">/// * ptr 执行要调整的内存块
</span><span style="color:#09f;font-style:italic">/// * size 要调整到的字节数
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// void *realloc(void *ptr, size_t size)
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    p <span style="color:#555">=</span> realloc(p,<span style="color:#f60">10</span><span style="color:#555">*</span><span style="color:#069;font-weight:bold">sizeof</span>(<span style="color:#078;font-weight:bold">char</span>));
    printf(<span style="color:#c30">&#34;realloc(p,10*sizeof(char))  %p</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>,p);
    p <span style="color:#555">=</span> realloc(p,<span style="color:#f60">10000</span><span style="color:#555">*</span><span style="color:#069;font-weight:bold">sizeof</span>(<span style="color:#078;font-weight:bold">char</span>));
    printf(<span style="color:#c30">&#34;realloc(p,10000*sizeof(char))  %p</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>,p);
    
<span style="color:#09f;font-style:italic">/// ### 回收先前分配的内存
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// void free(void *ptr)
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    free(p);
    
<span style="color:#09f;font-style:italic">/// ### 搜索环境变量并返回字符串
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// char *getenv(const char *name)
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    printf(<span style="color:#c30">&#34;getenv(</span><span style="color:#c30;font-weight:bold">\&#34;</span><span style="color:#c30">PATH</span><span style="color:#c30;font-weight:bold">\&#34;</span><span style="color:#c30">)  %.30s ...</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>, getenv(<span style="color:#c30">&#34;PATH&#34;</span>));
    
<span style="color:#09f;font-style:italic">/// ### 把命令(string)传递给主机由主机执行
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// int system(const char *string)
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    printf(<span style="color:#c30">&#34;system(</span><span style="color:#c30;font-weight:bold">\&#34;</span><span style="color:#c30">echo ok</span><span style="color:#c30;font-weight:bold">\&#34;</span><span style="color:#c30">)</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>);
    system(<span style="color:#c30">&#34;echo ok&#34;</span>);
    
<span style="color:#09f;font-style:italic">/// ### 快速排序
</span><span style="color:#09f;font-style:italic">/// * base是数组的基地址 
</span><span style="color:#09f;font-style:italic">/// * nitems是数组的元素个数 
</span><span style="color:#09f;font-style:italic">/// * size是数组元素大小
</span><span style="color:#09f;font-style:italic">/// * compar是比较函数，靠返回值正负来比较，为0的情况未定义
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// void qsort(void *base, size_t nitems, size_t size,
</span><span style="color:#09f;font-style:italic">///                 int (*compar)(const void *, const void*))
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    p <span style="color:#555">=</span> (<span style="color:#078;font-weight:bold">char</span> <span style="color:#555">*</span>)calloc(<span style="color:#f60">11</span>, <span style="color:#069;font-weight:bold">sizeof</span>(<span style="color:#078;font-weight:bold">char</span>));
    strcpy(p,<span style="color:#c30">&#34;5147096382&#34;</span>);
    qsort(p,<span style="color:#f60">10</span>,<span style="color:#069;font-weight:bold">sizeof</span>(<span style="color:#078;font-weight:bold">char</span>),cmptest);
    printf(<span style="color:#c30">&#34;qsort  &#34;</span>);
    printf(p);
    putchar(<span style="color:#c30">&#39;\n&#39;</span>);
    
<span style="color:#09f;font-style:italic">/// ### 二分查找
</span><span style="color:#09f;font-style:italic">/// * key是要查找的元素 
</span><span style="color:#09f;font-style:italic">/// * base是数组的基地址 
</span><span style="color:#09f;font-style:italic">/// * num是数组的元素个数 
</span><span style="color:#09f;font-style:italic">/// * size数组元素大小
</span><span style="color:#09f;font-style:italic">/// * cmp是比较函数，靠返回值正负来比较，数组必须是排好序的
</span><span style="color:#09f;font-style:italic">/// * 返回找到的元素的指针
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// void *bsearch(const void *key, const void *base, size_t num, size_t size,
</span><span style="color:#09f;font-style:italic">///                 int (*cmp)(const void *, const void *));
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    <span style="color:#078;font-weight:bold">char</span> a <span style="color:#555">=</span> <span style="color:#c30">&#39;3&#39;</span>; <span style="color:#09f;font-style:italic">/* 搜索a */</span>
    printf(<span style="color:#c30">&#34;bsearch  &#34;</span>);
    printf((<span style="color:#078;font-weight:bold">char</span> <span style="color:#555">*</span>)bsearch(<span style="color:#555">&amp;</span>a,p,<span style="color:#f60">10</span>,<span style="color:#069;font-weight:bold">sizeof</span>(<span style="color:#078;font-weight:bold">char</span>),cmptest));
    free(p);
    putchar(<span style="color:#c30">&#39;\n&#39;</span>);
    
<span style="color:#09f;font-style:italic">/// ### 返回x的绝对值
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// int abs(int x)
</span><span style="color:#09f;font-style:italic">/// long int labs(long int x)
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    printf(<span style="color:#c30">&#34;abs(-5)  %d</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>,abs(<span style="color:#555">-</span><span style="color:#f60">5</span>));
    
<span style="color:#09f;font-style:italic">/// ### 做除法，分别得到除数和被除数
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// div_t div(int numer, int denom)
</span><span style="color:#09f;font-style:italic">/// ldiv_t ldiv(long int numer, long int denom)
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    div_t div_out <span style="color:#555">=</span> div(<span style="color:#f60">7</span>,<span style="color:#f60">2</span>);
    printf(<span style="color:#c30">&#34;div(7,2)={%d,%d}</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>,div_out.quot,div_out.rem);
    
<span style="color:#09f;font-style:italic">/// ### 返回一个随机数，范围(0~RAND_MAX)
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// int rand(void)
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    printf(<span style="color:#c30">&#34;rand() = %d</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>,rand());
    
<span style="color:#09f;font-style:italic">/// ### 对随机函数设置种子
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// void srand(unsigned int seed)
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    srand(<span style="color:#f60">15</span>);
    
<span style="color:#09f;font-style:italic">/// ### 计算一个多字节字符的长度
</span><span style="color:#09f;font-style:italic">/// * n 是多字节字符的长度的最大值
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// int mblen(const char *str, size_t n)
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    wchar_t mywchar <span style="color:#555">=</span> <span style="color:#c30">L</span><span style="color:#c30">&#39;汉&#39;</span>;      <span style="color:#09f;font-style:italic">/* 换成&#39;国&#39;就不行了，不知道为什么 */</span>
    printf(<span style="color:#c30">&#34;mblen(&#39;%x&#39;,MB_CUR_MAX)  %u</span><span style="color:#c30;font-weight:bold">\n</span><span style="color:#c30">&#34;</span>,<span style="color:#c30">L</span><span style="color:#c30">&#39;汉&#39;</span>,mblen((<span style="color:#078;font-weight:bold">char</span> <span style="color:#555">*</span>)<span style="color:#555">&amp;</span>mywchar,MB_CUR_MAX));
    
<span style="color:#09f;font-style:italic">/// ### 多字节字符串转换为数组
</span><span style="color:#09f;font-style:italic">/// 将由参数str指向的多字节字符串转换为由pwcs指向的数组
</span><span style="color:#09f;font-style:italic">/// * n 是多字节字符的长度的最大值
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// size_t mbstowcs(schar_t *pwcs, const char *str, size_t n)
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>
<span style="color:#09f;font-style:italic">/*  todu 宽字符处理看不懂
</span><span style="color:#09f;font-style:italic">    int mbtowc(whcar_t *pwc, const char *str, size_t n)
</span><span style="color:#09f;font-style:italic">    Examines the multibyte character pointed to by the argument str.
</span><span style="color:#09f;font-style:italic">    
</span><span style="color:#09f;font-style:italic">    size_t wcstombs(char *str, const wchar_t *pwcs, size_t n)
</span><span style="color:#09f;font-style:italic">    Converts the codes stored in the array pwcs to multibyte characters and stores them in the string str.
</span><span style="color:#09f;font-style:italic">    
</span><span style="color:#09f;font-style:italic">    int wctomb(char *str, wchar_t wchar)
</span><span style="color:#09f;font-style:italic">    Examines the code which corresponds to a multibyte character given by the argument wchar.
</span><span style="color:#09f;font-style:italic">     */</span>
<span style="color:#09f;font-style:italic">/// ### 在程序正常退出时执行 
</span><span style="color:#09f;font-style:italic">/// * func 要执行的函数
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// int atexit(void (*func)(void))
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    atexit(test);
    
<span style="color:#09f;font-style:italic">/// ### 程序异常退出
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// void abort(void)
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    <span style="color:#09f;font-style:italic">/* abort(); */</span>
    
<span style="color:#09f;font-style:italic">/// ### 程序正常退出 ,返回给操作系统 status
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
</span><span style="color:#09f;font-style:italic">/// void exit(int status)
</span><span style="color:#09f;font-style:italic">/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color:#09f;font-style:italic"></span>    exit(<span style="color:#f60">0</span>);
}
</code></pre></div>
  </article>
</div>
      
<div class="grow"></div>
<nav class="pagination-single">
  
    
      <a href="http://shaochenfeng.com/blog/centos8yum%E5%AE%89%E8%A3%85nginx%E5%B9%B6%E8%AE%BE%E7%BD%AE%E8%99%9A%E6%8B%9F%E4%B8%BB%E6%9C%BA/" title="Centos8 Yum安装nginx并设置虚拟主机" class="pagination-single__left">
        <div class="pagination-single__icon">
          <svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0V0z"/><path fill="currentColor" d="M19 11H7.83l4.88-4.88c.39-.39.39-1.03 0-1.42-.39-.39-1.02-.39-1.41 0l-6.59 6.59c-.39.39-.39 1.02 0 1.41l6.59 6.59c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L7.83 13H19c.55 0 1-.45 1-1s-.45-1-1-1z"/></svg>
        </div>
        <div class="pagination-single__right-title">Centos8 Yum安装nginx并设置虚拟主机</div>
      </a>
    
    <div class="grow"></div>
    
      <a href="http://shaochenfeng.com/blog/%E5%85%B3%E4%BA%8E%E6%88%91/" title="关于我" class="pagination-single__right">
        <div class="pagination-single__left-title">关于我</div>
        <div class="pagination-single__icon">
          <svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0V0z"/><path fill="currentColor" d="M5 13h11.17l-4.88 4.88c-.39.39-.39 1.03 0 1.42.39.39 1.02.39 1.41 0l6.59-6.59c.39-.39.39-1.02 0-1.41l-6.58-6.6c-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.02 0 1.41L16.17 11H5c-.55 0-1 .45-1 1s.45 1 1 1z"/></svg>
        </div>
      </a>
    
  
</nav>


    </article>
    
    <section id="list-side" class="r" data-dir="ltr">
      
        <div class="toc">
  <h6 class="toc__label">目录</h6>
  <div class="toc__body">
    <nav id="TableOfContents">
  <ul>
    <li><a href="#宏">宏</a></li>
    <li><a href="#函数">函数</a></li>
    <li><a href="#数据类型">数据类型</a></li>
    <li><a href="#示例文件">示例文件</a></li>
  </ul>
</nav>
  </div>
</div>
      
    </section>

  </div>
</div>

<script>
  'use strict';
  
  function wrap(el, wrapper) {
    el.parentNode.insertBefore(wrapper, el);
    wrapper.appendChild(el);
  }

  (function () {
    var singleContentsElem = document.querySelector('.single__contents');
    singleContentsElem ? 
    singleContentsElem.querySelectorAll('pre > code').forEach(function(elem) {
      var dataLang = elem.getAttribute('data-lang');
      var dataLangWrapper = document.createElement('div');
      var code = null;
      var codeTitle = null;

      if (dataLang && dataLang.includes(':')) {
        code = dataLang.split(':')[0];
        codeTitle = dataLang.split(':')[1];

        dataLangWrapper.className = 'language-' + code;
        dataLangWrapper.setAttribute('data-lang', codeTitle);

        elem.className = 'language-' + code;
        elem.setAttribute('data-lang', codeTitle);
        elem.setAttribute('id', codeTitle);
      }

      if (!dataLang || codeTitle) {
        wrap(elem.parentNode, dataLangWrapper);
      }

    }) : null;
  })();
  


  
  
  var dollarCodeElem = document.querySelectorAll('div.language-\\$');
  var gtCodeElem = document.querySelectorAll('div.language-\\>');
  
  dollarCodeElem ?
  dollarCodeElem.forEach(function(elem) {
    var lnts = elem.parentNode.parentNode ? elem.parentNode.parentNode.querySelectorAll('.lnt') : null;
    lnts ? 
    lnts.forEach(function(lnt) {
      lnt.innerHTML = '$<br/>';
    }) : null;
  }) : null;

  gtCodeElem ?
  gtCodeElem.forEach(function(elem) {
    var lnts = elem.parentNode.parentNode ? elem.parentNode.parentNode.querySelectorAll('.lnt') : null;
    lnts ? 
    lnts.forEach(function(lnt) {
      lnt.innerHTML = '><br/>';
    }) : null;
  }) : null;
  
</script>




<script defer src="/js/helper/getParents.min.js"></script>

<script defer src="/js/helper/closest.min.js"></script>

<script defer src="/js/helper/prev.min.js"></script>

<script defer src="/js/helper/prop.min.js"></script>

<script defer src="/js/helper/fadeinout.min.js"></script>












<script>
  document.addEventListener('DOMContentLoaded', function () {
    'use strict';
    
    
    var tables = document.querySelectorAll('.single__contents > table');
    for (let i = 0; i < tables.length; i++) {
      var table = tables[i];
      var wrapper = document.createElement('div');
      wrapper.className = 'table-wrapper';
      table.parentElement.replaceChild(wrapper, table);
      wrapper.appendChild(table);
    }
    


    
    
    
    var lib = JSON.parse("null");

    if (lib && lib.includes('mermaid')) {
      var themeVariant = localStorage.getItem('theme') || 'light';

      if (themeVariant === "dark") {
        mermaid.initialize({ theme: 'dark' });
      } else {
        mermaid.initialize({ theme: 'default' });
      }
      
      var mermaids = [];
      [].push.apply(mermaids, document.getElementsByClassName('language-mermaid'));
      mermaids.forEach(function(elem) {
        var elemParentNode = elem.parentNode;

        if (elemParentNode !== document.body) {
          elemParentNode.parentNode.insertBefore(elem, elemParentNode);
          elemParentNode.parentNode.removeChild(elemParentNode);
        }

        var newElemWrapper = document.createElement('div');
        newElemWrapper.classList.add('mermaid');
        newElemWrapper.innerHTML = elem.innerHTML;
        elem.replaceWith(newElemWrapper);
      });
    }
    
    

    
    if (lib && lib.includes('katex')) {
      var mathElements = document.getElementsByClassName('math');
      var options = {
        delimiters: [
          { left: "$$", right: "$$", display: true },
          { left: "\\[", right: "\\]", display: true },
          { left: "$", right: "$", display: false },
          { left: "\\(", right: "\\)", display: false }
        ],
      };

      renderMathInElement(document.querySelector('.single__contents'), options);
    }
    


    
    if (lib && lib.includes('flowchartjs')) {
      
      var options = JSON.parse("{\"arrow-end\":\"block\",\"element-color\":\"black\",\"fill\":\"white\",\"flowstate\":{\"approved\":{\"fill\":\"#58C4A3\",\"font-size\":12,\"no-text\":\"n/a\",\"yes-text\":\"APPROVED\"},\"current\":{\"fill\":\"yellow\",\"font-color\":\"red\",\"font-weight\":\"bold\"},\"future\":{\"fill\":\"#FFFF99\"},\"invalid\":{\"fill\":\"#444444\"},\"past\":{\"fill\":\"#CCCCCC\",\"font-size\":12},\"rejected\":{\"fill\":\"#C45879\",\"font-size\":12,\"no-text\":\"REJECTED\",\"yes-text\":\"n/a\"},\"request\":{\"fill\":\"blue\"}},\"font-color\":\"black\",\"font-size\":14,\"line-color\":\"black\",\"line-length\":50,\"line-width\":3,\"no-text\":\"no\",\"scale\":1,\"symbols\":{\"end\":{\"class\":\"end-element\"},\"start\":{\"element-color\":\"green\",\"fill\":\"yellow\",\"font-color\":\"red\"}},\"text-margin\":10,\"x\":0,\"y\":0,\"yes-text\":\"yes\"}");
      var jsonContent = null;

      var flowchartPrefix = "language-flowchart";
      var index = 0;
      Array.prototype.forEach.call(document.querySelectorAll("[class^=" + flowchartPrefix + "]"), function(x){
          x.style.display = 'none'
          x.parentNode.style.backgroundColor = "transparent"
          jsonContent = x.innerText;

          var node0 = document.createElement('div');
          node0.id = 'flowchart' + index;
          x.parentNode.insertBefore(node0, x);

          var diagram = flowchart.parse(jsonContent);
          diagram.drawSVG("flowchart"+index, options);

          index +=1;
      });      
    }
    


    
    if (lib && lib.includes('chart')) {
      var borderColor = "#666";
      var bgColor = "#ddd";
      var borderWidth = 2;

      Chart.defaults.global.elements.rectangle.borderWidth = borderWidth;
      Chart.defaults.global.elements.rectangle.borderColor = borderColor;
      Chart.defaults.global.elements.rectangle.backgroundColor = bgColor;

      Chart.defaults.global.elements.line.borderWidth = borderWidth;
      Chart.defaults.global.elements.line.borderColor = borderColor;
      Chart.defaults.global.elements.line.backgroundColor = bgColor;

      Chart.defaults.global.elements.point.borderWidth = borderWidth;
      Chart.defaults.global.elements.point.borderColor = borderColor;
      Chart.defaults.global.elements.point.backgroundColor = bgColor;

      var chartPrefix = "language-chart";
      var index = 0;
      var jsonContent = null;

      Array.prototype.forEach.call(document.querySelectorAll("[class^=" + chartPrefix + "]"), function (x) {
        x.style.display = 'none'
        x.parentNode.style.backgroundColor = "transparent"
        jsonContent = x.innerText;
        var node0 = document.createElement('canvas');
        var source = null;
        node0.height = 200;
        node0.style.height = 200;
        node0.id = 'myChart' + index;
        source = JSON.parse(jsonContent);
        x.parentNode.insertBefore(node0, x);
        var ctx = document.getElementById('myChart' + index).getContext('2d');
        var myChart = new Chart(ctx, source);
        index += 1;
      });            
    }
    


    
    if (lib && lib.includes('viz')) {
      var vizPrefix = "language-viz-";
      Array.prototype.forEach.call(document.querySelectorAll("[class^=" + vizPrefix + "]"), function (x) {
        x.style.display = 'none'
        x.parentNode.style.backgroundColor = "transparent"
        var engine;
        x.getAttribute("class").split(" ").forEach(function (cls) {
          if (cls.startsWith(vizPrefix)) {
            engine = cls.substr(vizPrefix.length);
          }
        });
        var viz = new Viz();
        viz.renderSVGElement(x.innerText, { engine: engine })
          .then(function (element) {
            element.style.width = "100%";
            x.parentNode.insertBefore(element, x);
          })
      });
    }
    
    
  });
</script>

<script>
  var singleMenu = document.getElementById('single-menu');
  var listMain = document.getElementById('list-main');
  var listSide = document.getElementById('list-side');
  var wideViewAsDefault = JSON.parse("null");

  enquire.register("screen and (max-width:1280px)", {
    match: function () {
      if (wideViewAsDefault) {
        singleMenu.className = 'hide';
        listMain.className = 'lm';
        listSide.className = 'r';
      } else {
        singleMenu.className = 'l';
        listMain.className = 'm';
        listSide.className = 'r';
      }
    },
    unmatch: function () {
      if (wideViewAsDefault) {
        singleMenu.className = 'hide';
        listMain.className = 'lm';
        listSide.className = 'r';
      } else {
        singleMenu.className = 'l';
        listMain.className = 'm';
        listSide.className = 'r';
      }
    },
  }).register("screen and (max-width:960px)", {
    match: function () {
      listSide.className = 'r';
      listMain.className = 'lm';
      singleMenu.className = 'hide';
    },
    unmatch: function () {
      if (wideViewAsDefault) {
        singleMenu.className = 'hide';
        listMain.className = 'lm';
        listSide.className = 'r';
      } else {
        singleMenu.className = 'l';
        listMain.className = 'm';
        listSide.className = 'r';
      }
    },
  }).register("screen and (max-width:600px)", {
    match: function () {
      listSide.className = 'hide';
      listMain.className = 'lmr';
      singleMenu.className = 'hide';
    },
    unmatch: function () {
      listSide.className = 'r';
      listMain.className = 'lm';
      singleMenu.className = 'hide';
    },
  });
</script>

        
<div class="bot">
  <footer class="footer">
    <div class="divider">
      <div class="lmr">
        
          <p class="caption">
            <a href="https://beian.miit.gov.cn/" target="_blank">冀ICP备18002899号</a>    ©2021, All Rights Reserved
          </p>
          
        
      </div>
    </div>
  </footer>
</div>

    </div>

</body>

</html>